{"name":"regexReplace","operator":null,"title":"regexReplace","type":"command","url":"https://community.bistudio.com/wiki/regexReplace","revid":349515,"updated":"2023-11-08T17:14:41Z","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 given *haystack* with given *pattern* and replaces all matches with given *replaceString*.","syntaxes":[{"syntax":"haystack regexReplace [pattern, replaceString]","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":"replaceString","type":"String","optional":false,"default":null,"description":"[Reference](https://www.boost.org/doc/libs/1_76_0/libs/regex/doc/html/boost_regex/format/perl_format.html)","types":["String"],"since":null,"text":"replaceString: String - [Reference](https://www.boost.org/doc/libs/1_76_0/libs/regex/doc/html/boost_regex/format/perl_format.html)"}],"returns":{"type":"String","types":["String"],"description":"modified text","text":"String - modified text"},"form":"binary","operator":null,"left":{"text":"haystack","types":["String"]},"right":{"text":"[pattern, replaceString]","types":["Array"]}}],"examples":[{"text":"```sqf\n\"wookie boOkie cookie\" regexReplace [\".oo/gio\", \"[$']\"];                        // \"[kie boOkie cookie]kie [kie cookie]kie [kie]kie\"\n```","code":["\"wookie boOkie cookie\" regexReplace [\".oo/gio\", \"[$']\"];\t\t\t\t\t\t// \"[kie boOkie cookie]kie [kie cookie]kie [kie]kie\""]},{"text":"```sqf\n\"wookie boOkie cookie\" regexReplace [\".oo/gio\", \"[$&]\"];                        // \"[woo]kie [boO]kie [coo]kie\"\n```","code":["\"wookie boOkie cookie\" regexReplace [\".oo/gio\", \"[$&]\"];\t\t\t\t\t\t// \"[woo]kie [boO]kie [coo]kie\""]},{"text":"```sqf\n\"wook1e boOk2e cook3e\" regexReplace [\".oo/gio\", \"[$`]\"];                        // \"[]kie [k1e ]k2e [k2e ]k3e\"\n```","code":["\"wook1e boOk2e cook3e\" regexReplace [\".oo/gio\", \"[$`]\"];\t\t\t\t\t\t// \"[]kie [k1e ]k2e [k2e ]k3e\""]},{"text":"```sqf\n\"wook1e boOk2e cook3e\" regexReplace [\".(oo)(.*?)e\", \"[$2]\"];                    // \"[k1] [k2] [k3]\"\n```","code":["\"wook1e boOk2e cook3e\" regexReplace [\".(oo)(.*?)e\", \"[$2]\"];\t\t\t\t\t// \"[k1] [k2] [k3]\""]},{"text":"```sqf\n\"wOokie boOkie cookie\" regexReplace [\".(?<test>oo)kie/gio\", \"[$+{test}]\"];    // \"[oo] [oO] [oo]\"\n```","code":["\"wOokie boOkie cookie\" regexReplace [\".(?<test>oo)kie/gio\", \"[$+{test}]\"];\t// \"[oo] [oO] [oo]\""]},{"text":"```sqf\n// Make captured group all lower case '\\L' (lower case) or '\\U' (upper case)\n\"ArmA 3 is so awesome!\" regexReplace [\"(rmA 3)\", \"\\L$1\"]; // \"Arma 3 is so awesome!\"\n```","code":["// Make captured group all lower case '\\L' (lower case) or '\\U' (upper case)\n\"ArmA 3 is so awesome!\" regexReplace [\"(rmA 3)\", \"\\L$1\"]; // \"Arma 3 is so awesome!\""]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["regexMatch","regexFind"],"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"]}