Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Am I missing something? Is there a PCRE option to escape special literals in the replace parameter?

$
0
0

I'm trying to improve some code and was wondering is there some parameter/command in which I don't always have to escape special literals using _StringRegExpMetaCharacters? As it really increases the speed since I'm replacing entire functions. StringReplace is just even slower.

Local $sData = FileRead(@ScriptFullPath), $sReplace = '-\*--*\-' ; $sData = StringRegExpReplace($sData, '\Q(\E', $sReplace) ; This doesn't work correctly. ; Replace ( with *--* $sReplace = _StringRegExpMetaCharacters($sReplace) $sData = StringRegExpReplace($sData, '\Q(\E', _StringRegExpMetaCharacters($sReplace)) ConsoleWrite('Replacement String: ' & $sReplace & @CRLF & @CRLF) ConsoleWrite($sData & @CRLF) Func _StringRegExpMetaCharacters($sString) ; By guinness 2013.     Return StringRegExpReplace($sString, '([].|*?+(){}^$\\[])', '\\\1') EndFunc   ;==>_StringRegExpMetaCharacters

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>