Alteryx Designer Discussions

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

Trim function on a string ?

Highlighted
11 - Bolide

Hi,

 

How do I get from:  1234567890

 

To:  456

 

?

 

Thanks in advance.

Highlighted
11 - Bolide

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

Highlighted
8 - Asteroid

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

Substring([FIELDNAME],3,3)

Highlighted
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...

Highlighted
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

Highlighted
11 - Bolide

I like it thank you.

Highlighted
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.
Alteryx Partner
 
Highlighted
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.

Highlighted
11 - Bolide

TrimRight([city],'county')

Labels