Alteryx Designer Desktop Discussions

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

How do I extract part of a string from Field Info?

sonseeahray
8 - Asteroid

How do I go about extracting a portion of the Field info string?

 

I have a set of Excel files that I need to pull 3 digits from the filename and am trying to do that via the field info string.

 

All of the files have 12 leading alpha numeric characters. I need to extract positions 10-12 and am not up to speed on reg-ex.

 

Sample: 1234-678-012... the "678" position numbers are the same with all the files, so I'm sure it's possible to pull the 3 characters to the right of the "678-" string, I don't know reg-ex well enough yet.

7 REPLIES 7
TonyA
Alteryx Alumni (Retired)

You don't need regex for this one. If you just need the 10th - 12th characters use a substring function in a formula tool. If the string is in field F1: 

 

Substring([F1],9,3)

 

(You need to start from character 9 because string position numbering starts at 0.)

afv2688
16 - Nebula
16 - Nebula

Hello @sonseeahray ,

 

Based on your example only I used the following tool:

 

I used this formula => REGEX_Replace([Field1], '^\d+\-(\d+)\-(.*)', '$1')

 

Sin título.png

Based on what you tell you could also use the following => Substring([Field1],10,3)

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Regards

sonseeahray
8 - Asteroid

@TonyA @afv2688 You guys are awesome! I am going to hold on to both of these! Thank you!

nicoarmisen
5 - Atom

Hi @afv2688 ,

maybe yo can help me hier. I need to "translate" from SQL the following expression:

UPDATE Tmp_Station_Details_All_Slc
SET Main_Station = 'N'
WHERE SUBSTR(STATION_CODE,5,2)='38' AND COUNTRY_CODE ='DE';

I need to extract first the last two characters from the station code and if it is equal to 38 and the country code is DE upgrade Main_Station as 'N'. Is not, then do Nothing.

Thank you in advance!

Nico

aihnen
8 - Asteroid

Use formula tool on the column Main_Station with an IF statement with 2 conditions

 

IF

SUBSTRING(STATION_CODE, 5, 2) = '38'

AND

COUNTRY_CODE = 'DE'

THEN

Main_Station = 'N'

ENDIF

Linguine
7 - Meteor

This is my solution!!

 

Linguine
7 - Meteor

wait wrong discussion

 

Labels