Is there some trick to searching for a plain unadorned dollar sign occurring in text with a regular expression? I'm trying to replace the two characters $ when followed by one or two digits with a single character $ followed by the digit(s) found. I've lost sight of the answer in a downpour of baffling backslashes ... :-)
like this:
(replace {\$} {abc$cde} "x" 0) => "abcxcde"
(replace "\\\$" "abc\$cde" "x" 0) => "abcxcde"
- both the backslash and the dollar sign are special characters in regular expression patterns (not the string, only the pattern) and have to be escaped by a
- additionally when using quotes "" than a backslash is also a special character for newLISP. and must be esacped by a .
- the {,} in newLISP takes all chracters literally, makeing things a bit easier.
Lutz
... so in my examples I am actually replacing two character: the backslash and a dollar sign with an 'x'. Nor sure if you meant, the dollar sign only:
(replace {$} {abc$cde} "x" 0) => "abcxcde"
(replace "\$" "abc$cde" "x" 0) => "abcxcde"
Lutz