Re: regex for numbers with spaces and letter O
2021/10/15 16:19:58
(permalink)
This is a really tricky and interesting problem, to do with RegEx! I found out that 3 replacement are needed in exactly the order given below, to achieve this. See below, and when entering them, remember that there can't be any spaces in the Pattern or Replace fields, only the characters that I marked in bold, and be sure to distinguish the capital O letter from the narrower 0 (zero).
First replace multiple O O sequences with 00:
Type: Regular Expression (RegEx)
Pattern: O\s*O
Replace: 00
Then replace remaining O with 0, if they are preceded by a digit:
Type: Regular Expression (RegEx)
Pattern: (\d\s*)(O)
Replace: $10
Finally remove the spaces between digits:
Type: Regular Expression (RegEx)
Pattern: (\d)(\s+)(?=\d)
Replace: $1
Greg