I have an interesting problem. I need to create database-sort-friendly versions of names, where all definite and indefinite articles are dropped from the beginning of each name.
I came up with this formula:
IF(REGEX_MATCH(Name,'^THE'),
SUBSTITUTE(Name, LEFT(Name, 4), ''),
IF(REGEX_MATCH(Name, '^A'),
SUBSTITUTE(Name, LEFT(Name, 2), ''),
IF(REGEX_MATCH(Name, '^AN'),
SUBSTITUTE(Name, LEFT(Name, 3), ''),
Name
)))
But it’s not working for names that start with “AN”. The formula is deleting all "AN"s.
Why is it working with “THE” and “A”, but not with “AN”?
What am I missing? I am at a loss.
Thank you in advance!