6,824625
Grand MasterGrand Master
6,824625

PostJun 04, 2021#16

A Perl regular expression search string (?<=\d),(?=\d) with a positive lookbehind and a positive looahead works also for removing all commas between two digits.

Is is also possible to run a Perl regular expression replace all with search expression (?<=\d),(?=\d+\.\d) and an empty replace string two or even more times until UltraEdit reports that the searched string was not found in file.

14
Basic UserBasic User
14

PostJun 04, 2021#17

Thank you very much fleggy for \d\K,(?=[\d,]+?\.)

I need a favor from you. Can you just explain me this regular expression?

19276
MasterMaster
19276

PostJun 04, 2021#18

\d   find a number
\K   selection will start here and not from the beginning
,     comma after the \d
(?=    the next pattern is a test of the following text, so called look ahead
[\d,]    the following text must contain only numbers or commas
+?       as few as possible, one at least. E.g. 2222,5,,455,  :)
\.         and then the dot must follow
)     end of the look ahead

The look ahead is simply a test and not a part of matched text. If the test fails then the particular comma is not matched. E.g. 123,XX does not pass the lookahead test (X is neither a number nor a comma)

Read more posts (-12 remaining)