0

I have a row that looks like this:

'ABCD','ABKCKD','ADFL','3','43

In UltraEdit, I am trying to find '3',' and replace that as 3, I tried to find as ['][\d]+['][,]['] and found '3','

However, when I tried to replace it as [\d]+[,], it doesn't work.

Any ideas?

Thanks.

Alfabravo
  • 7,493
  • 6
  • 46
  • 82

2 Answers2

0

You first need to capture the number between the quotes, you can do it like this using capturing group ():

'([\d]+)','

then use the captured digit using ^1 so your replace would be : ^1,

Ultraedit regex usage reference

Ashish Ranjan
  • 5,523
  • 2
  • 18
  • 39
0

UltraEdit has support for 3 different regular expression engines:

  • Perl ... the most powerful regexp engine using Boost Perl regexp library.
  • UltraEdit ... the native regexp engine of UltraEdit with syntax like in Microsoft Office.
  • Unix ... UltraEdit regexp engine with Perl regexp syntax (more or less).

The IDM power tip tagged expressions explains the usage of marking/capturing/tagging groups on running an UltraEdit regular expression replace.

The IDM power tip Perl regular expressions: Backreferences explains the usage of marking/capturing groups on running a Perl regular expression replace. This syntax can be also used for legacy Unix regexp engine with limited capabilities.

[...] defines a character class/set, i.e. a list of characters. Any character within the square brackets can or must be found for a positive search. Using a character set does not make much sense for a single character like ' and ,. It is possible to use ['][\d]+['][,]['], but it is much easier to use as search string '\d+','.

Please note that the escape sequence \d in a Unix/Perl regexp search string defines a characters set for any digit. The equivalent in an UltraEdit and by chance also in Unix/Perl regexp search string is [0-9].

The replace can be done with search string '^([0-9]+^)',' and replace string ^1,' on using UltraEdit regular expression engine.

The replace can be done with search string '(\d+)',' and replace string \1,' on using Unix or Perl regular expression engine.

With the Perl regexp engine it is also possible to use for this replace the search string '(\d+)'(?=,') with replace string \1 because of ,' is specified in a positive lookahead which does not match/select characters.

Mofi
  • 46,139
  • 17
  • 80
  • 143