>>
> local regexObj > local specialChars, specialCharsPattern, replacePattern > > local i > > specialChars = '\^$.[]()|{}*+?' > > replacePattern = '\$&' && or '\$1' > regexObj = createObject('VBScript.RegExp') > regexObj.IgnoreCase = false > regexObj.Global = true > > && construct specialCharsPattern > specialCharsPattern = '(' > > for i = 1 to len(m.specialChars) > specialCharsPattern = m.specialCharsPattern + '\' + substr(m.specialChars, m.i, 1) + '|' > endfor > specialCharsPattern = left(m.specialCharsPattern, len(m.specialCharsPattern)-1) + ')' > > regexObj.Pattern = m.specialCharsPattern > > > && examples > local inputSearchString, useSearchString > > inputSearchString = m.specialChars > useSearchString= regexObj.Replace(m.inputSearchString , m.replacePattern ) > ?'inputSearchString: ', m.inputSearchString > ?'useSearchString: ', m.useSearchString > > > inputSearchString = 'a( $ )' > useSearchString= regexObj.Replace(m.inputSearchString , m.replacePattern ) > ?'inputSearchString: ', m.inputSearchString > ?'useSearchString: ', m.useSearchString >More efficient to just do
specialChars = "(\\|\^|\$|\.|\[|\]|\(|\)|\||\{|\}|\*|\+|\?)"
and get rid of the for/endfor ?