Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Extract a Single Characted from a String

Tommy_Alterax
8 - Asteroid

Hi Guys,

 

I'm wondering can Reg Ex tool be used (Without Text to columns) in order to extract the first alphabetical charater in a string when reading from left to right

 

12874-0001BDUSDXXXXXXXXX

 

For example above it would be "D" - Going from left to right

 

Thanks 🙂

18 REPLIES 18
Tommy_Alterax
8 - Asteroid

Sorry that should be "B" above

atcodedog05
22 - Nova
22 - Nova

Hi @Tommy_Alterax 

 

Here is a workflow for the task.

Regextool config:

atcodedog05_0-1605096980083.png

 

Output:

atcodedog05_1-1605097025529.png

 

Hope this helps 🙂


If this post helps you please mark it as solution. And give a like if you dont mind 😀👍

Tommy_Alterax
8 - Asteroid

Worked a dream - Thank You !!!!! 🙂 - Can you explain to me whats happening with the Reg ex tool here - What does tokenise mean ?

atcodedog05
22 - Nova
22 - Nova

Hi @Tommy_Alterax 

 

[[:alpha:]] is regex for alphabet character. By setting to tokenize it gets all the alphabetical character splitting them into columns depending on the numbers of columns set. Since i have set 1 it just showing one character column.

 

Hope this helps🙂

Tommy_Alterax
8 - Asteroid

Stupied question - Why doesnt it keep other alpha characters in the string ?  (I dont want them just wondering) 

atcodedog05
22 - Nova
22 - Nova

Hi @Tommy_Alterax 

 

So just [[:alpha:]] is single character [[:alpha:]]+ is one or more. So + and * are used to catch more characters. Click on the option highlighted it will give you a list.

 
 
 

Capture.PNG

This link gives more idea on the usage

https://community.alteryx.com/t5/Alteryx-Designer-Knowledge-Base/RegEx-Perl-Syntax-Guide/ta-p/1288

 

Hope this helps 🙂

MarqueeCrew
20 - Arcturus
20 - Arcturus

@Tommy_Alterax ,

 

Left to right it should be "B"....

 

left(trimleft([Field1],"0123456789-"),1)

 

This formula returns B.  It can be modified to read right to left too (unlike RegEx).  It also runs faster than RegEx.

 

Cheers,

 

Mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
Tommy_Alterax
8 - Asteroid

Is it posible to use this regex in a formulae tool - For example I have 6 different data types - Only if it is equal to data type '3' do I want the reg ex to execute

atcodedog05
22 - Nova
22 - Nova

Hi @Tommy_Alterax 

 

Yes it is possible. Depending on the requirement.

 

Can you please me a sample data, expect output and explain the logic.

 

Will be happy to help 🙂

Labels