0

I would like to use regex to replace every other comma in a text string with a Pipe to make it easier to parse.

This is how the string looks: 121234 SMITH, ALEX, 19512 JONES, ASHLEY, 400011 POPIO, CIRO, 162222 JANIS, LORI A, 12345 LEMON, KAREN, 66111 MORAN, LISA M, 111807 BRIGGS, CHERYL

This is how it should look after regex: 121234 SMITH, ALEX|19512 JONES, ASHLEY|400011 POPIO, CIRO|162222 JANIS, LORI A|12345 LEMON, KAREN|66111 MORAN, LISA M|111807 BRIGGS, CHERYL

I think I need to target the ", " that is in front of a number somehow.

Dharman
  • 30,962
  • 25
  • 85
  • 135
user2232552
  • 133
  • 1
  • 1
  • 8
  • Looks like you are looking to create a regex, but do not know where to get started. Please check [Reference - What does this regex mean](https://stackoverflow.com/questions/22937618) resource, it has plenty of hints. Also, refer to [Learning Regular Expressions](https://stackoverflow.com/questions/4736) post for some basic regex info. Once you get some expression ready and still have issues with the solution, please edit the question with the latest details and we'll be glad to help you fix the problem. – Wiktor Stribiżew Mar 31 '20 at 15:28
  • Specify your programming language. – Robert Harvey Mar 31 '20 at 15:29
  • [Advanced Regex: Find and Replace Every Second Instance Of A Character](https://levelup.gitconnected.com/advanced-regex-find-and-replace-every-second-instance-of-a-character-c7d97a31516a) – Robert Harvey Mar 31 '20 at 15:30
  • Thank you I will take a look. I figured out a slightly longer solution but definitely will review these resources. – user2232552 Mar 31 '20 at 16:39
  • Best to learn a little, try something, fail a bit, and then post the attempt. You get better (or at least some) answers. For this example consider: https://regex101.com/r/0bAdK4/1 – MDR Mar 31 '20 at 19:18

0 Answers0