{"name":"regexFind","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","games":{"arma3":"2.06"},"since":"arma3 2.06","arma3_since":"2.06","description":"Searches in a string with a regular expression.\n\n> [!NOTE]\n> See Arma 3: Regular Expressions.","syntaxes":[{"syntax":"haystack regexFind [pattern, startOffset]","params":[{"name":"haystack","type":"String","type_expr":"String"},{"name":"pattern","type":"String","description":"format regex pattern","type_expr":"String"},{"name":"startOffset","type":"Number","optional":true,"default":"0","description":"has to be in range from 0 to `count haystack` (*haystack*'s length)","type_expr":"Number","text":"startOffset: Number - (Optional, default 0) has to be in range from 0 to `count haystack` (*haystack*'s length)"}],"returns":{"type_expr":"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\n- 0: String - match\n- 1: Number - offset of given match relative to *haystack* beginning (the provided *offset* is ignored)"},"form":"binary","left":{"text":"haystack"},"right":{"text":"[pattern, startOffset]"}}],"examples":[{"code":["\"wooKie boOkie cookie\" regexFind [\".ookie/gio\"]; // [[[\"wooKie\", 0]], [[\"boOkie\", 7]], [[\"cookie\", 14]]]"]},{"code":["\"wooKie boOkie cookie\" regexFind [\".ookie/i\"]; // [[[\"wooKie\",0]]]"]},{"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]]]"]},{"code":["\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e/i\"]; // [[[\"cookie\",6], [\"oo\", 7], [\"i\", 10]]]"]},{"code":["\"I'm a cookie clicker\" regexFind [\"c(.*?)k(.*?)e\"]; // [[[\"cookie\", 6], [\"oo\", 7], [\"i\", 10]], [[\"clicke\", 13], [\"lic\", 14], [\"\", 18]]]"]}],"see_also":["regexMatch","regexReplace"]}