I'm writing an regex to create col2 and fill it with cp1 if respects condition else "not" if not.
The condition is if f1== name***/state/ then col2 will contains cp1 else col2 will contains "NOT".
I wrote the code below
when trim(f1) ~ '^name[^/]*/state/' then 'cp1'
else "not" as col2
I'm getting bad results as shown in the attached images.
Does anyone knows how to solve it please?
Actual_output

Expected_output

Thank you,