Column Expressions - Wildcare Replace Value

Hi Everyone!

I am not fluent with Regex and I think what I am trying to achieve would be easier on Regex.

I have a column of Sizes and it is messy and generally not clean and might consist of weird typos.
I am currently using Column Expression Node to try to append a column with a cleaner set of Sizes.

Some examples of the typos are like SHT instead of Short, LNG instead of Long, also different Capitalization of words, 0XL instead of just XL, XXXL instead of 3XL.

I am trying to use “*” as a wildcard to cover my bases with the possible typos.
But it seems like my expression is not picking up my wildcard; 0XL is still being classified as Standard instead of XL. Is my expression of “*XL” incorrect?

This is my Expression:

"duplicate = not( column(“duplicate-type-classifier”) == “unique” )
Long = or( (column(“Size 1”) == “* L * NG”), (column(“Size 1”) == “* l * ng”) )
Short = or( (column(“Size 1”) == “* SH * T”), (column(“Size 1”) == “* sh * t”) )
XXXL = or( (column(“Size 1”) == “*XXXL”), (column(“Size 1”) == “*3XL”) )
XXXS = or( (column(“Size 1”) == “*XXXS”), (column(“Size 1”) == “*3XS”) )
XL = or( (column(“Size 1”) == “*XL”), (column(“Size 1”) == “XL”) )
XS = or( (column(“Size 1”) == “*XS”), (column(“Size 1”) == “XS”) )

if(
and(duplicate, Long))
“Long”
else if(
and(duplicate, Short))
“Short”
else if(
and(duplicate, XXXL))
“3XL”
else if(
and(duplicate, XXXS))
“3XS”
else if(
and(duplicate, XL))
“XL”
else if(
and(duplicate, XS))
“XS”
else “Standard” "

Hi @neekstressed,

do you happen to have a minimal example workflow you could share? That may make it a bit easier to understand and help out for the community. :slight_smile:

Additionally, in general, when you’re working with or learning about regular expressions, https://regex101.com/ is a fantastic resource to help understand and debug your expressions.

Kind regards
Marvin

2 Likes