We are aware of an issue with the Search bar. Please use Advanced search for the time being while we troubleshoot. Thanks for your patience as we work on improving the community!

Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
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
16 - Nebula
16 - Nebula

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

 

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

NicoleJohnson
14 - Magnetar
14 - Magnetar

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.

LisaL
Alteryx
Alteryx

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
Senior Customer 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