community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

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

Trim function on a string ?

Bolide

Hi,

 

How do I get from:  1234567890

 

To:  456

 

?

 

Thanks in advance.

Bolide

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

Highlighted
Asteroid

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

Substring([FIELDNAME],3,3)

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

 

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

Magnetar
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

Bolide

I like it thank you.

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
Customer Support Engineer -- Knowledge Management Coach
Alteryx, Inc.
Alteryx Partner
 
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.

Bolide

TrimRight([city],'county')

Labels