Hi, I'm bringing in some data like the below and having a difficult time getting the expected output.
name | expectedOutput |
The Name Test | N |
-Company Name | C |
(k)Name, LLC | k |
Test | T |
4 Your Test | 4 |
Using the below formula, I'm able to get all of the expected outputs except for the last one that starts with a number
if StartsWith([name],'the') then Substring([name],4,1)
elseif (REGEX_Match([name],'[a-zA-Z].*') or REGEX_Match([name],'\d.*[a-zA-Z]') = 1) then Substring([name],0,1)
else Substring([name],1,1)
endif
TEST OUTPUT:
name | TEST Output |
The Name Test | N |
-Company Name | C |
(k)Name, LLC | k |
Test | T |
4 Your Test |
Not sure what I'm missing. TIA
Solved! Go to Solution.
In your second REGEX_Match you have " = 1"
Remove the = 1 and it works fine.
@ChrisTX thanks. I figured it was something simple I was missing. I noticed when I added that to the production data there was an issue with a string that started with a number and ended with a number. For example, "2 TEST2" came back as an empty field with leading and trailing whitespaces.
To fix it I changed the regex_match to:
from:
(REGEX_Match([name],'[a-zA-Z].*') or REGEX_Match([name],'\d.*[a-zA-Z]'))
to:
(REGEX_Match([name],'[a-zA-Z].*') or REGEX_Match([name],'\d.*'))