Run first a Perl regular expression with search string
\<(\d\d)\> and replace string
0.\1 and run next a second Perl regular expression replace with
\d\K(\d\d)\> as search string and
.\1 as replace string.
The result for the tab separated input example data is:
Code: Select all
304.34 -0.38 0.38
285.32 -0.35 0.35
14.46 -0.02 0.02
-14.46 0.02 -0.02
-285.32 0.35 -0.35
-304.34 0.38 -0.38
4267.70 9.51 0.10 4.07 5.34
-4267.70 -9.51 -0.10 -4.07 -5.34
The search string
\<(\d\d)\> means:
\< ... find a string at beginning of a word. Space, horizontal tab, line-feed, hyphen, dot are not word characters. So a word is for the Perl regular expression just a series of digits for the input data.
(...) ... mark the string found by the expression inside the first pair of round brackets for being back-referenced in search or replace string with
\1 as done in the replace string to keep the two digits.
\d\d ... find two digits.
\> ... the two digits must be at end of a word.
In other words this search expression matches only numbers with exactly two digits. The minus sign (in real the hyphen character) is not a word character.
he replace string inserts the digit 0 and a dot left to the two found digits which are kept due to back-referencing them.
The second search expression
\d\K(\d\d)\> means:
\d ... find a digit.
\K ... keep back the matched digit which means unselect the already matched digit and start selecting found string from this position in character stream.
(...) ... mark the string found by the expression inside the first pair of round brackets for being back-referenced in search or replace string with
\1 as done in the replace string to keep the two digits.
\d\d ... find two digits.
\> ... the two digits must be at end of a word for a positive match.
In other words the search expression searches for three digits at end of a word, ignores the first digit for the replace and inserts a dot left the two found digits which are kept due to back-referencing them.