I'm doing a RE Replace, and here are the results I get.
Scenario #1
Find what: \xFF
Replace with: \
Result: Replaces ÿ with \
Scenario #2
Find what: \xFF
Replace with: \\
Result: Replaces ÿ with \
Scenario #3
Find what: \xFF
Replace with: \\\\
Result: Replaces ÿ with \\
The Replace with value would seem to resolved from RE into a literal if it's a valid RE (Scenarios #2 and #3), but otherwise it's treated as a literal (Scenario #1).
I am guessing it has always been that way, but should it?
Sanity Check on a RE Replace
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
Sanity Check on a RE Replace
(2[Bb]|[^2].|.[^Bb])
That is the question.
That is the question.
-
ben_josephs
- Posts: 2464
- Joined: Sun Mar 02, 2003 9:22 pm
When regular expression is selected, certain characters in the replacement expression (the "replacement format string") have special meanings.
TextPad's help, under Reference Information | Replacement Format Strings, states:
Note that a replacement format string is not a regular expression.
TextPad's help, under Reference Information | Replacement Format Strings, states:
It would appear that, as a convenience to the user, if a backslash stands alone in a replacemnet expression (or is unpaired at the end of a replacemnet expression), so that it plainly is not quoting anything, it's treated as a literal. The alternative would be to treat it as an error and annoy the user.These format strings treat all characters as literals except for '$', '\', '(', ')', '?', and ':'. To output any of those characters as a literal, precede it with a '\'.
Note that a replacement format string is not a regular expression.