Is there a simple way to strip all special characters from a string?

  • 22 June 2017
  • 4 replies
  • 29 views

Badge +3

For purposes of building a URL for a link, I am stripping special characters like comma, period and question mark from a string (created by a user entry):

fn-Replace({TextStart}{ItemProperty:Title}{TextEnd},{textstart},{textend},)

This is working great, but I'm wondering if there is some operator that I can use to refer to all special characters, or if there is an entirely different approach that would deliver the desired result.

Ideas?


4 replies

Userlevel 5
Badge +14

imho, better option would be to use regular expression.

where do you do it, in forms or workflow?

Badge +9

Marian is right. Here is an example using a character class in regex replacing all characters not in class by empty string.

^ Match a single character not present in the list below
[^w]
w matches any word character (equal to [a-zA-Z0-9_])
in place of w You can use a list of all allowed characters.

204941_pastedImage_1.png

Badge

Great...How about if i want to keep only "/"

Badge +9

as w matches any letter, digit or underscore which is equivalent to [a-zA-Z0-9_] You can use

[^a-zA-Z0-9_/]

Reply