- Not working.
Find:Replace with:Code: Select all
$0
\& will still be matched in new syntax, only for text without line breaks.Code: Select all
[$&]
- Old syntax.
Find:Replace with:Code: Select all
\&
Code: Select all
[&]
TextPad Help says regex $0 for selected text corresponds to & in old syntax but the Find function can't match it
Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard
TextPad Help says regex $0 for selected text corresponds to & in old syntax but the Find function can't match it
Example:
Last edited by AmigoJack on Thu Jul 25, 2024 7:51 am, edited 1 time in total.
Reason: formatting
Reason: formatting
Re: TextPad Help says regex $0 for selected text corresponds to & in old syntax but the Find function can't match it
Isn't the whole sense of $0 to be used in a potential replacement instead of a finding? Just like $1, $2, $3 etc. are used for groupings in the match? Using $0 means the whole matching regex without any groupings, so using it to find anything becomes logically impossible, since it would refer to itself.
I did my best to format your post despite your settings to not parse any BBCode (mainly because then it's less ambiguous what your actual regex/replacement should be, secondly to have a true list) - is this the replacement you really wanted? An opening square bracket, then your whole match, then a closing square bracket?
Yes: such a feature does not exist. In contrast to f.e. Notepad++ TextPad can handle very big files and use search & replace on those in a timely manner, while Notepad++ takes a very long time. Folding lines surely comes with a performance impact somewhere, and I'm glad TextPad doesn't have it so far.
-
- Posts: 2461
- Joined: Sun Mar 02, 2003 9:22 pm
Re: TextPad Help says regex $0 for selected text corresponds to & in old syntax but the Find function can't match it
As AmigoJack writes, using $0 in a search expression makes no sense.
It matches the end of a line ($) followed by a "0". But that sequence exists nowhere, as the end of a line is followed by a newline character sequence (1 or 2 characters).
Keep in mind that regexes and replacements are entirely different things and have different syntaxes.
It matches the end of a line ($) followed by a "0". But that sequence exists nowhere, as the end of a line is followed by a newline character sequence (1 or 2 characters).
Keep in mind that regexes and replacements are entirely different things and have different syntaxes.
Thanks for your replies!
If you please could suggest a replacement expression for putting, say, brackets around (a few lines of) selected text. Or just a find string to match any selected text.
Sorry for unintended confusion. I looked for an alternative to \& in a wrong place:
Replacement Format Syntax Conversion
Old & (probably the POSIX syntax used prior to TextPad 7)
Perl/JavaScript $0
If you please could suggest a replacement expression for putting, say, brackets around (a few lines of) selected text. Or just a find string to match any selected text.
Sorry for unintended confusion. I looked for an alternative to \& in a wrong place:
Replacement Format Syntax Conversion
Old & (probably the POSIX syntax used prior to TextPad 7)
Perl/JavaScript $0
Re: TextPad Help says regex $0 for selected text corresponds to & in old syntax but the Find function can't match it
If you lookup Perl Modifiers in the section on Regular Expression Syntax in the help file, it explains how to match over multiple lines using "(?s)". Hence, to quote a multi-line string, select it then:
Find what: (?s).+
Replace with: "$0"
Replace All in Selected Text.
Find what: (?s).+
Replace with: "$0"
Replace All in Selected Text.