Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

First letter from a string after 'The' or special characters

BonusCup
10 - Fireball

Hi, I'm bringing in some data like the below and having a difficult time getting the expected output.

 

nameexpectedOutput
The Name TestN
-Company Name

C

(k)Name, LLCk
TestT
4 Your Test4

 

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:

nameTEST Output
The Name TestN
-Company NameC
(k)Name, LLCk
TestT
4 Your Test 

 

Not sure what I'm missing.  TIA

2 REPLIES 2
ChrisTX
16 - Nebula

In your second REGEX_Match you have " = 1"

 

Remove the = 1 and it works fine.

 

BonusCup
10 - Fireball

@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.*'))

Polls
We’re dying to get your help in determining what the new profile picture frame should be this Halloween. Cast your vote and help us haunt the Community with the best spooky character.
Don’t ghost us—pick your favorite now!
Labels