Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

classification builder - regex for multiple values that adjust

Avatar

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct Reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
Level 4
scottt6073095
Level 4

Likes

66 likes

Total Posts

102 posts

Correct Reply

3 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
scottt6073095
Level 4

10-07-2018

Hi All,

Having some difficulties figuring out how to create regex that adjusts to the number of groups.

I can have any number of parts ranging from 1 to 4

strings:

events:company-conferences/company-user-conference/2018

events:company-conferences/company-user-conference

events:company-conferences

I tried this regex however it only returns the correct values if it has 4 capture groups, no more no less.

^([^\:]*)\:([^\:]*)\/([^\:]*)\/([^\:]*)

1525466_pastedImage_8.png

I tried the below regex however it does the same

^(.+)\:(.+)\/(.+)\/(.+)

is there regex logic that is flexible to the number of capture groups in a string? I would like to capture string that have groups up to 4 but may have 3 or 2.

any help would be highly appreciated.

thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 1
Level 1
spencerh7639004
Level 1

Likes

2 likes

Total Posts

2 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 1
Level 1
spencerh7639004
Level 1

Likes

2 likes

Total Posts

2 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Applaud 5
Affirm 1
View profile
spencerh7639004
Level 1

17-07-2018

Something like : ^(.+)\:(.+?)(\/|$)(.*?)(\/|$) (repeating (.*?)(\/|$) to the number of possible results will get you in even numbered fields the results you want.  So for 1-4:

^(.+)\:(.+?)(\/|$)(.*?)(\/|$)(.*?)(\/|$)(.*?)(\/|$)

You can see the results here: https://regexr.com/3sjh5

Answers (2)

Answers (2)

Avatar

Avatar
Boost 5
Level 2
JimKultgen
Level 2

Likes

15 likes

Total Posts

15 posts

Correct Reply

2 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Applaud 5
View profile

Avatar
Boost 5
Level 2
JimKultgen
Level 2

Likes

15 likes

Total Posts

15 posts

Correct Reply

2 solutions
Top badges earned
Boost 5
Boost 3
Boost 10
Boost 1
Applaud 5
View profile
JimKultgen
Level 2

17-07-2018

I do something similar in which I essentially have a different rule for either 5 or 6 fields.  Not sure if there is a more robust way but this should be easy to build from for 2/3/4 fields.  As an FYI my deliminator is an underscore.

^((.+)\_(.+)\_(.+)\_(.+)\_(.+)\_(.+)|(.+)\_(.+)\_(.+)\_(.+)\_(.+))$

sample Regex.png

Avatar

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

78 likes

Total Posts

358 posts

Correct Reply

82 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile

Avatar
Give Back 50
Level 6
pabloc82923542
Level 6

Likes

78 likes

Total Posts

358 posts

Correct Reply

82 solutions
Top badges earned
Give Back 50
Give Back 5
Give Back 3
Give Back 25
Give Back 10
View profile
pabloc82923542
Level 6

18-07-2018

Check out this thread see if it helps.

Regex help in Classification Rule Builder