Search code examples
regexperlultraedit

How to eval in Ultraedit regex Replace


In Ultraedit using perl Regex, I am trying to replace a strings DATA0 with DATA8, DATA1 with DATA9, and so on. I know how to get the match to happen in Ultraedit's Find Dialog using DATA\d.

In order to capture the digit, I use DATA(\d), and in the "Replace With:" box I can access the group with $1, DATA$1+8 but this, obviously, results in text DATA0+8, which makes sense.

Is there an eval() that can be done in Ultraedit's replace dialog in order to modify the captured group variable $1?

I realize this can be done in the javascript integration with Ultraedit, but I would rather be able to do this out of the box from the Replace Dialog.


Solution

  • No, UltraEdit can't do that.

    You could actually use Perl

    perl -i.bak -pe"s/DATA\K(\d+)/$1+8/eg" "C:\..."       5.10+
    
    perl -i.bak -pe"s/(DATA)(\d+)/$1.($2+8)/eg" "C:\..."