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

Question

Question

Removing a character from a string

asked on April 5, 2017 Show version history

Hello everyone,

What is the regular expression I should use in the Workflow token dialog if I want to remove a character (in this case, a single quote) from anywhere in a string?

Thanks,

Julie

0 0

Answer

SELECTED ANSWER
replied on April 5, 2017

If you're doing it with pattern matching within the token syntax, that's expected behavior as it will only return the first match. 

You can use the Pattern Matching activity to create a new token. In this activity you can specify whether you want just the first match or all of them.

An alternative would be to use the Token Calculator activity and its Replace function to replace the single quote to with the empty string.

2 0

Replies

replied on April 5, 2017

You can use the [^ ] to exclude characters. ([ ] is used for specifying characters in a range, like [a-c]. [^a-c] is characters not in the specified range, or "anything but a-c"). So, something like [^']+ should do it.

0 0
replied on April 5, 2017

Thanks, although that only returns characters before a quote. So if I have a string like D'Anna, it only returns D. I just want it to strip out a character regardless of where it is in the string.

Asking more broadly, is there a simple way in workflow just to strip out a character? I don't have to use regular expressions. It doesn't look like any of the functions in the token dialog would do it, unless I am missing something.

0 0
SELECTED ANSWER
replied on April 5, 2017

If you're doing it with pattern matching within the token syntax, that's expected behavior as it will only return the first match. 

You can use the Pattern Matching activity to create a new token. In this activity you can specify whether you want just the first match or all of them.

An alternative would be to use the Token Calculator activity and its Replace function to replace the single quote to with the empty string.

2 0
replied on April 7, 2017

Thanks, although when I open the Token Calculator, it does not have Replace as a function (only Add, Subtract, Multiply, Sum, Average, Divide). What version are you referring to?

The Pattern Matching approach works - thanks!!

Julie

0 0
replied on April 7, 2017

Oh, you're on an older version. The function set was expanded for Workflow 10.

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

Sign in to reply to this post.