Link to home
Start Free TrialLog in
Avatar of tmajor99
tmajor99

asked on

Regular Expression to replace spaces after certain letters

I need help with a regex to check for a letter and space following.  I need to replace all the spaces between letters "G, L, P, M, H, S".  

Data:            Results
--------------    ------------
1.2 G P M     1.2 GPM
99 L P M        99 LPM    
1.5 L P S        1.4 LPS
88 G P S        88 GPS
Avatar of Howard Cantrell
Howard Cantrell
Flag of United States of America image

Here's one you can play with
(?:[\A-Z]\+ *)|\h
Try replacing:
(?<=[GLPMHS])\h(?=[GLPMHS])

Open in new window

with an empty string.
ASKER CERTIFIED SOLUTION
Avatar of Frank Helk
Frank Helk
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial