1

Have this text sequence, how do we get it to look like desired output.

AAAAAAA ................................................ 28.02%
AAAAA-BBBBB, AB ........................................ 16.50%
AAAAAAA ................................................ 28.02%
AAAAA-BCCCC, AB ........................................ 16.50%
CCCCCCC ................................................ 28.02%
AAAAA-DDDDD, AB ........................................ 16.50%
FFFFFFF ................................................ 28.02%
AAAAA-BBBBB, AB ........................................ 16.50%

Trying to get into a format like this --

AAAAAAA | 28.02%
AAAAA-BBBBB, AB | 16.50%
AAAAAAA | 28.02%
AAAAA-BBBBB, AB |16.50%
AAAAAAA | 28.02%
AAAAA-BBBBB, AB | 16.50%

Using Pipe delimiter, that way I can load it into DB (since I can't use commas,they're in the first part of the string).

so far I've tried this - without much success, any help would be appreciated. Using Notepad++ for processing the regex.

\.(?!$)
replace with blank

4 Answers4

2

You can simply match the dots(minimum 2 otherwise dot inside float value will also match which is not required here) and replace with the pipe | character,

Match : \.{2,}

Replace: |

REGEX DEMO: https://regex101.com/r/HxVFbl/1

A l w a y s S u n n y
  • 36,497
  • 8
  • 60
  • 103
1

Try Finding: ([^.]+) \.+ (.+)

and replacing with: $1 | $2

Explanation

Find: ([^.]+) \.+ (.+)

  • ([^.]+) - all that is not a dot '.' in a capture group (#1)
  • \.+ - space, one or more dots ..., space
  • (.+) - simply the rest of the string in another capture group (#2)

Replace: $1 | $2

  • $1 - contents of capture group #1
  • | - space, pipe, space
  • $2 - contents of capture group #2
dvo
  • 2,113
  • 1
  • 8
  • 19
  • 1
    I'm not a fan of using `\.+` to match the series of dots, because a decimal number also has a single dot in it. See the Sunny answer for an alternative. – Tim Biegeleisen Dec 03 '19 at 16:15
1

Don't be panic, it could be done super easily, just forget above all complex answers. just select dots one or more with white space, and there you go.

(\.+ )

Then replace with pipe and white space(| ) character

Demo: https://regex101.com/r/yoxb9U/3

Omar
  • 901
  • 11
  • 14
0

You can use the below regex

Match: [.]+

Replace: |

stud3nt
  • 2,056
  • 1
  • 12
  • 21