0

I'm using UltraEdit in Perl regex mode to do that. i.e. (cat) (dog) replaced with $0\n$1 $2

Although the $1 and $2 worked, I couldn't find a way to make $0 work.

Does anyone experience this issue?

simbabque
  • 53,749
  • 8
  • 73
  • 136
jonah_w
  • 972
  • 5
  • 11
  • 1
    If `$0` doesn't work then group the whole pattern and then use `$1` for whole match – Pushpesh Kumar Rajwanshi May 02 '19 at 07:26
  • Thanks @PushpeshKumarRajwanshi I was thinking about that solution, but was really curious why `$0` doesn't work on UltraEdit, I've tried `$0` on Sublime Text, and it works fine. – jonah_w May 02 '19 at 07:31
  • Yes, in some regex dialects `$0` works like in Java also it works but in some other dialects it doesn't work, as it seems just not supported, hence that's the obvious and easy workaround. – Pushpesh Kumar Rajwanshi May 02 '19 at 07:33
  • 1
    I'll go with that method if couldn't find another way. Thanks for the explanation. – jonah_w May 02 '19 at 07:36

1 Answers1

1

When using "Perl" regular expressions in Ultra Edit,

  • $& contains the matched text.
  • $` contains the portion of the document leading up to the matched text.
  • $' contains the portion of the document following the matched text.

This is documented here. (Scroll down to "Perl regex output modifiers".)

This is consistent with Perl, where $0 contains the first argument to the program (the name of the program).

Screenshot of Demonstration

ikegami
  • 367,544
  • 15
  • 269
  • 518