We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

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
11 - Bolide

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
16 - Nebula

In your second REGEX_Match you have " = 1"

 

Remove the = 1 and it works fine.

 

BonusCup
11 - Bolide

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

Labels
Top Solution Authors