ACE3/addons/common/functions/fnc_escapeRegex.sqf
jonpas 742626ff1a
General - Relative script_component.hpp includes (#9378)
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
2023-09-12 20:58:10 +02:00

21 lines
475 B
Plaintext

#include "..\script_component.hpp"
/*
* Author: LinkIsGrim
* Escapes special characters used in regex from a string
*
* Arguments:
* 0: String <STRING>
*
* Return Value:
* Safe string <STRING>
*
* Example:
* "\Q.*?AK-15.*?\E" call ace_common_fnc_escapeRegex
*
* Public: Yes
*/
params [["_string", "", [""]]];
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
_string regexReplace ["[.?*+^$[\]\\(){}|-]/gio", "\\$&"]