Alteryx Designer Desktop Discussions

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

Trim function on a string ?

Brad1
11 - Bolide

Hi,

 

How do I get from:  1234567890

 

To:  456

 

?

 

Thanks in advance.

12 REPLIES 12
Brad1
11 - Bolide

Right(Left([PHONE],6),3)

sjm
8 - Asteroid

Here's one approach, assuming the field is a string:

Substring([FIELDNAME],3,3)

patrick_digan
17 - Castor
17 - Castor

If you always want the 4-6th characters, you could use: Substring([Field1],3,3)

 

EDIT: @sjm beat me to the punch...

NicoleJohnson
ACE Emeritus
ACE Emeritus

Two more options, just for kicks :)

 

If you always want to trim the exact same string from the left & right:

TrimRight(TrimLeft([Field1],”123”),”7890”)

 

If you always want to trim the same number of digits from the left & right:

RegEx_Replace([Field1],”\d{3}(\d{3})\d{4}”,”$1”)

 

NJ

Brad1
11 - Bolide

I like it thank you.

lepome
Alteryx Alumni (Retired)

By that logic, TrimRight([County ],' County') should work, but it trims all of the letters within the string from the right, not just the complete string.  Moral:  Verify.County.png

Lisa LePome
Principal Support Engineer -- Knowledge Management Coach
Alteryx, Inc.
mmccowin
6 - Meteoroid
 
Nicko
5 - Atom

I agree with you, but what is the solution then? If I want it only to remove a specific string segment? In your example "County" from the end of the string.

Brad1
11 - Bolide

TrimRight([city],'county')

Labels