In respond to:
12345678 TXT 19700101 0 100 20160624 100 Comment text
12345678 TXT 19700101 100 100,25 20160624 0,25 Comment text
12345678 TXT 19700101 100,25 100,5 20160624 0,25 Comment text
For 4th column:
^((?:\S+\s+){3}\d+)(\s)
to \1,0\2
^((?:\S+\s+){3}\d+,\d)(\s)
to \10\2
For 5th/7th column:
similar to above, just replace {3}
with {4}
/{6}
in the rule respectively
Explanation
The 1st rule appends ,0
to numbers without ,
. Now all numbers must have ,\d
.
The 2nd rule appends a 0
to those with single digit after comma.
As for (?:)
:non-capture group, the previous columns are already captured as \1
so additional capturing is unnecessary.
This only pads number to 2 decimal places. To pad an arbitrary amount, use the pad excessively, then trim
approach.
Final word?
In my opinion, plain regex as in notepad++ is inadequate for this task. Some basic scripting like bash or perl would have handled this with much higher readability.
Best Answer
You can use the RegEx find and replace option.
Search for
Replace with
Explanation:
The search is:
^
- Beginning of the line\s
- A whitespace character*
- 0 or more of them(
- Begin a capture group\w
- A word character ([a-z] or [A-Z]).
- Any character*
- 0 or more of them)
- End our capture group$
- End of the lineReplace with:
\1
- The contents of the first capture group (Our word character and all characters after that)