{"name":"regexFind","operator":null,"title":"regexFind","type":"command","url":"https://community.bistudio.com/wiki/regexFind","revid":369430,"updated":"2024-09-03T18:48:53Z","groups":["Strings - Regular Expression"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"2.06"}],"since":{"game":"arma3","name":"Arma 3","version":"2.06"},"arma3_since":"2.06","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Searches in a string with a regular expression.\n\n> [!NOTE]\n> See Arma 3: Regular Expressions.","syntaxes":[{"syntax":"haystack regexFind [pattern, startOffset]","since":null,"effect":null,"exec":null,"params":[{"name":"haystack","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"haystack: String"},{"name":"pattern","type":"String","optional":false,"default":null,"description":"format regex pattern","types":["String"],"since":null,"text":"pattern: String - format regex pattern"},{"name":"startOffset","type":"Number","optional":true,"default":"0","description":"has to be in range from 0 to `count haystack` (*haystack*'s length)","types":["Number"],"since":null,"text":"startOffset: Number - (Optional, default 0) has to be in range from 0 to `count haystack` (*haystack*'s length)"}],"returns":{"type":"Array of nested arrays. Each lowest level array in format:","types":["Array"],"description":"0: String - match - 1: Number - offset of given match relative to haystack beginning (the provided offset is ignored)","text":"Array of nested arrays. Each lowest level array in format:\n- 0: String - match\n- 1: Number  - offset of given match relative to *haystack* beginning (the provided *offset* is ignored)"},"form":"binary","operator":null,"left":{"text":"haystack","types":["String"]},"right":{"text":"[pattern, startOffset]","types":["Array"]}}],"examples":[{"text":"```sqf\n\"wooKie boOkie cookie\" regexFind [\".ookie/gio\"]; // [[[\"wooKie\", 0]], [[\"boOkie\", 7]], [[\"cookie\", 14]]]\n```","code":["\"wooKie boOkie cookie\" regexFind [\".ookie/gio\"]; // [[[\"wooKie\", 0]], [[\"boOkie\", 7]], [[\"cookie\", 14]]]"]},{"text":"```sqf\n\"wooKie boOkie cookie\" regexFind [\".ookie/i\"]; // [[[\"wooKie\",0]]]\n```","code":["\"wooKie boOkie cookie\" regexFind [\".ookie/i\"]; // [[[\"wooKie\",0]]]"]},{"text":"```sqf\n\"wooKie boOkie cookie\" regexFind [\".ookie/\"]; // [[[\"cookie\", 14]]]\n```","code":["\"wooKie boOkie cookie\" regexFind [\".ookie/\"]; // [[[\"cookie\", 14]]]"]},{"text":"Multiline example:\n\n```sqf\n\"co1kie2\nco2kie\" regexFind [\"^co.kie$\"]; // [[[\"co2kie\",9]]]\n```","code":["\"co1kie2\nco2kie\" regexFind [\"^co.kie$\"]; // [[[\"co2kie\",9]]]"]},{"text":"```sqf\n\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e/i\"]; // [[[\"cookie\",6], [\"oo\", 7], [\"i\", 10]]]\n```","code":["\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e/i\"]; // [[[\"cookie\",6], [\"oo\", 7], [\"i\", 10]]]"]},{"text":"```sqf\n\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e\"]; // [[[\"cookie\", 6], [\"oo\", 7], [\"i\", 10]], [[\"clicke\", 13], [\"lic\", 14], [\"\", 18]]]\n```","code":["\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e\"]; // [[[\"cookie\", 6], [\"oo\", 7], [\"i\", 10]], [[\"clicke\", 13], [\"lic\", 14], [\"\", 18]]]"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["regexMatch","regexReplace"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Strings - Regular Expression","Introduced with Arma 3 version 2.06","Scripting Commands"]}