I’m trying to use the split
expression function using a regex expression, but cannot get this working…
I want to pull out the R G B values from a HEX colour (e.g. “#FF23DE”) using:
R = split(replace({New Template.Colour_HEX},'#',''), "[0-9a-fA-F]{2}")[0,0]
G = split(replace({New Template.Colour_HEX},'#',''), "[0-9a-fA-F]{2}")[1,0]
B = split(replace({New Template.Colour_HEX},'#',''), "[0-9a-fA-F]{2}")[2,0]
but this just give an error ArrayIndexOutOfBoundsException: 1
The dataset i get is 0R x 1C
I’ve tried this expression in a regex tester (https://regexr.com/) and it works as expected.
I know I can work around this using left() and right(), but I’d like to get it working with regex.
Thanks in advance.
Edit:
I just realised that the regex is what the split is looking for as text to split the string by, not the logic to use to split it… in which case I’m not sure how you could use a regex expression to your advantage?
In any case, can I achieve what I need using split and regex? My thoughts now would be no…