-1

I'm trying to use Regex to classify groups of data dependent on how many sectors are within an array. E.g.:

group = One journey
group|group = Two journeys
group|group|group = Three journeys

Could someone tell me the best practice way to do this please?

EDIT: Apologies but I'm pretty new to RegEx and still trying to work things out. I don't know which language I'm using but the tool I'm building these into is Adobe Analytics - using the Classification Rule Builder.

Also, this question has been marked as duplicate but I can't say I found the other thread particularly helpful.

I've also tried experimenting using Regex101 but still can't get my head around this. Thanks.

Emma
  • 27,428
  • 11
  • 44
  • 69
Lauren
  • 9
  • 1

1 Answers1

1

For such a case you need to capture what you want to match inside some block that would depend on the language you are using. For example, if you are using Python you can use:

(\w+)

This regex will allow you to capture and count every repetition of word characters, that is [a-zA-Z0-9_], that will be able to capture all the text you have between pipes.

By the way, in order to test your regex and to do some basic training and trial-error approach you can use tools like this one.

Drubio
  • 1,157
  • 3
  • 13
  • 30