You are viewing limited content. For full access, please sign in.

Question

Question

Token Functions - 'remove if text matches'

asked on February 19, 2016 Show version history

I'd like to remove the 'year' out of a field value.  For example, I want to remove '2015' out of the field value '2015 test' so that I end up with just 'test'  

Can someone tell me what I'm doing wrong here?

0 0

Answer

SELECTED ANSWER
replied on February 19, 2016

Instead of apply function, do Apply Regular Expression with (\D+) to pick up any non digit charaters

 

2 0
replied on February 22, 2016

This works, but I added \s to get rid of the space after the number.

 

 

replied on February 22, 2016

I added a space before (\D+) to get rid of the space after 2015.  Or the other solution was to add \s

 

 

token - 2nd.png
token - 2nd.png (19.49 KB)
0 0

Replies

replied on February 19, 2016

Is there always 4 digit number followed by text?  if so, you can use something like \d\s*(.*)

 

The solution by Tommy will remove all numeric values, so may be more aggressive than you need/want.

2 0
replied on February 22, 2016

I tried using this solution but it didn't work:

 

test token.png
test token.png (15.45 KB)
0 0
replied on February 22, 2016

Actually, that works as written. Your regular expression has a space before the "\d", so it matches the end of the " 99999". You have the space, then first "9" is covered by \d, then zero or more spaces (zero in this case), then some other characters.

0 0
replied on February 22, 2016

I tried it without the space, and this is what I got:

 

test token.png
test token.png (15.27 KB)
0 0
replied on February 19, 2016

Your slash is backwards in the regular expression. The function does not support regular expression for the value to remove.

But as Tommy and Bert indicate, you can use regular expression directly to get the numbers out.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.