Free Trial

Alteryx Designer Desktop Discussions

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

How to find the index of the first alpha numeric character in a string

npd
5 - Atom

Hello Users,

 

I have a requirement to find the index of the first Alpha numeric Character.

 

Example:

Input:      output 

,,..Apple   4

&&CAR    2

 

Thanks in advance

4 REPLIES 4
BrandonB
Alteryx
Alteryx

There may be a more elegant way, but this works: 

 

BrandonB_0-1648676212309.png

 

 

 

binuacs
21 - Polaris

@npd 

binuacs_0-1648678000963.png

 

kelly_gilbert
13 - Pulsar

@binuacs - watch out - the non-word character class (\W) also excludes underscores (so your solution wouldn't handle _123, for example). Also, I'm not sure if @npd's requirement needs to handle something like A.B.C, where there are non-alphanumeric characters after the first alphanumeric.

 


@npd - here's an alternative regex solution. This will return -1 if the string does not contain any alphanumeric characters.

FindString([input], REGEX_Replace([input], '^.*?[A-Za-z\d](.*)', '$1')) - 1


This finds the rest of the string after the first alphanumeric character.

 

kelly_gilbert_0-1648772426922.png

apathetichell
19 - Altair

tokenize and summarize.pngIt seems more "Alteryx" to me to do this via tokenizing, tile tool and summarize.

Labels
Top Solution Authors