Expand my Community achievements bar.

Classification Rule Builder - Matching Specific Values in a sub-string

Avatar

Level 1

In order to optimize the use of our evars and props, we use pipe-delimiters to string together values and then use the Classification Rule Builder to parse them out into classifications for reporting.  For example, eVar99 might be mapped to 'abc123||1|consent|trigger||||||'. The classification rules below would break those out into our classifications that are named like '(v99c) Mobile Client Type', etc.  

 

In most cases, we just parse out the value that is mapped and that's all we need to do. However, in this case, on rule 3, we want to say "if positions 3 = 1 then (v99c) Mobile Client Type = 'Native'. Otherwise it equals 'Not Native', while leaving the remaining rules in place.

 

Does anyone know how to do this? Thanks in advance.

 

v99 Classifications.jpg

3 Replies

Avatar

Community Advisor

Phew, regexes will never be fun to look at!

 

Well, since javascript regexes don't support if/else conditions, maybe this post is helpful https://stackoverflow.com/questions/32852857/javascript-conditional-regular-expression-if-then-else


Stupid question: have you talked to a dev to fix this on the website / data layer? Seems to be the easier approach than introducing conditions into regexes.

 

 

Cheers from Switzerland!


Avatar

Level 1

Thank you, Bjoern! I'll take a look at that post. I wondered about whether I'd be able to do what I wanted. I can go get the value changed. I was hoping I could get around it for the sake of history.

Cheers from Southern USA!

Avatar

Community Advisor

Hi @Kim_Reynolds - I tried this in a sandbox and it worked. 

Set the top rule to RegExp ^[^\|]*\|[^\|]*\|([1])\| v99 as set classification and "Native" (if the 3rd element contains only 1, then it's true and Native will be set)

Set the next rule to RexExp ^[^\|]*\|[^\|]*\|([^1]) v99 as set classification and "Non-Native" (if the 3rd element contains anything other than 1, then it's true and Non-Native will be set

If you need to test or update the logic for the 2nd rule, see this link for regex101.com.

 

 

Josh__Stephens_1-1742938550457.png