Expand my Community achievements bar.

SOLVED

Classification rule builder - create buckets for the values

Avatar

Level 4

The values are storing in eVar, we have to group / buckets the values. I think the best way is to do classification rule builder 

I would like to create buckets for the values like this:

0 – 3000

3001 -5000

5001 -10000

10001 – 30000

30001 – 50000

50001 – max

Can any one help me on this how to bucket / group the values in the regex or suggest me how to achieve above scenario.

Thanks all

@All  

1 Accepted Solution

Avatar

Correct answer by
Community Advisor and Adobe Champion

Regex for numbers is hard... since Regex is based on text values.. it doesn't recognize numerical values, it doesn't understand the concept of greater than / less than.. this means you will have to come up with complex regex rules that break the numbers down into expect values based on position and length.

 

Here is an article that explains how to create regex for numeric ranges:

https://www.regextutorial.org/regex-for-numbers-and-ranges.php

 

I also suggest you should use a tool like https://www.regextester.com/ to populate a bunch of values so that you can check that the rules you create match your expected output.

 

Good luck.

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor and Adobe Champion

Regex for numbers is hard... since Regex is based on text values.. it doesn't recognize numerical values, it doesn't understand the concept of greater than / less than.. this means you will have to come up with complex regex rules that break the numbers down into expect values based on position and length.

 

Here is an article that explains how to create regex for numeric ranges:

https://www.regextutorial.org/regex-for-numbers-and-ranges.php

 

I also suggest you should use a tool like https://www.regextester.com/ to populate a bunch of values so that you can check that the rules you create match your expected output.

 

Good luck.

Avatar

Community Advisor

Here's something that's not immediately obvious about Classification Rule Builder: you can have more than one rule that classify a single eVar. AA will process the rules from #1 to #last.

So you could do the following:

Rule Number       Regex                                                               Classified Value

1                           *                                                                        Max

2                           ^(3000[1-9]|3[1-9][0-9]{3}|4[0-9]{4}|50000)$     30001 - 50000

3                           ^(1000[1-9]|1[1-9][0-9]{3}|2[0-9]{4}|30000)$     10001 - 30000

etc

Note: I have not tested any of the above regexes!

When you've set it up correctly, then when you test this rule set, you should (hopefully) get back your expected buckets.

Avatar

Level 4

Thanks all for the reply.

I have found Regex Numeric Range Generator URL https://3widgets.com/ . I think it will be helpful for all us.