#include <Constants.au3>
MsgBox($MB_SYSTEMMODAL, '', _StringStripChar('This is the C:\Example__Test.*', '\_*'))
MsgBox($MB_SYSTEMMODAL, '', _StringStripChar('It''s not \E\Q, but instead EQ.', '\E\Q'))
; #FUNCTION# ====================================================================================================================
; Name ..........: _StringStripChar
; Description ...: Strip certain characters from a given string.
; Syntax ........: _StringStripChar($sString, $sChars)
; Parameters ....: $sString - String to strip character from.
; $sChars - Characters to be stripped.
; Return values .: Success - String with replaced characters
; Failure - Original string and sets @error to non-zero.
; Author ........: guinness
; Related .......: http://www.autoitscript.com/forum/topic/96454-my-new-udf/
; Link ..........: http://www.autoitscript.com/forum/topic/96454-my-new-udf/
; Example .......: Yes
; ===============================================================================================================================
Func _StringStripChar($sString, $sChars)
If $sChars == '' Then Return SetError(1, 0, $sString)
If $sString == '' Then Return SetError(2, 0, $sString)
$sChars = StringReplace($sChars, '\E', 'E\')
$sChars = StringReplace($sChars, '\Q', 'Q\')
Return StringRegExpReplace($sString, '[\Q' & $sChars & '\E]', '')
EndFunc ;==>_StringStripChar