You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Xed version 3.4.5
* Distribution - Linux Mint 21.3 Cinnamon
Issue
Regex replace does not use captured groups ()
Steps to reproduce
Select Search and replace from the menu with multiline text
Search for a regex pattern with a subgroup i.e abc(123) with the text aabc1234
Attempt to use the captured pattern with the variable $1 in the replace
Expected behaviour
The variable $1 will be expressed as the captured text 123
Instead, the replacement text will feature $1 as the literal replacement text
Other information
The text was updated successfully, but these errors were encountered:
Capture groups work, but for back-references, Xed uses \1 etc instead of $1 (this is also common in many terminal apps like sed). Disclaimer: Though I don't believe there should be any difference, I am testing from Fedora Cinnamon instead of on Mint. I am using Xed 3.4.5
the quick red fox jumped over the fence and fell flat on its face
search pattern using capture group + back reference
(the) quick.*\1 fence
will correctly highlight as follows:
the quick red fox jumped over the fence
Possibly the ticket could be changed to "Request Xed support both \1 and $1 style backreferences" when using capture groups (similar to perl / prename and some other apps).
That would probably avoid confusion for people who are only familiar with the Perl/Java/JavaScript variants of Regex (which are actually a lot more common these days) while not really disrupting folks used to the Posix-style back references much except possibly forcing them to escape dollar signs in the replace expression.
Or alternately, could possibly be user-configurable which style back-references Xed should use.
Issue
Regex replace does not use captured groups ()
Steps to reproduce
Select Search and replace from the menu with multiline text
Search for a regex pattern with a subgroup i.e abc(123) with the text aabc1234
Attempt to use the captured pattern with the variable $1 in the replace
Expected behaviour
The variable $1 will be expressed as the captured text 123
Instead, the replacement text will feature $1 as the literal replacement text
Other information
The text was updated successfully, but these errors were encountered: