$escregexp

Please add the scripting function

$escregexp(string) escape all special characters in string, making a literal regular expression

Meanwhile one may use

$regexp(.|*?+(){}'['']'^$,'([.|*?+(){}[]^$])',\\1)

e.g.

$regexp(A$A,'['$regexp(.|*?+(){}'['']'^$,'([.|*?+(){}[]^$])',\\1)']',S)

One may use the following to get the same escaping effect ...

$regexp(A$A,'[$replace('.|*?+(){}[]^$',.,\.,|,\|,*,\*,?,\?,+,\+,(,\(,),\),{,\{,},\},'[','\[',']','\]',^,\^,$,\$)]',S)
which gives "ASA".

... or completely literalized ...

$regexp('A$A', '['$replace('.|*?+(){}[]^$', '.','\.','|','\|','*','\*','?','\?','+','\+','(','\(',')','\)', '{','\{','}','\}','[','\[',']','\]','^','\^','$','\$')']','S')

... or ...

$regexp('A$A','['$regexp('.|*?+(){}[]^$','([].|*?+(){}$^[])','\\\1')']','S')

DD.20090809.1633.CEST, DD.20150227.1716.CET

I was seeking a less not more verbose alternative, Detlev :slight_smile:

Do your alternatives have an advantage over the original?

... hmm, it needs no regexp machine, but only internally string manipulations, so it could be executed some ticks quicker, I think so, and it is better to read and understand for no-regex-people.

DD.20090809.1710.CEST

I see. Thanks.