Basically I use the SystemException.Message in REFramework. There I have bullet points (\u2022) and new lines at the moment.
How do you want to escape them?
\W
can be used in regex to identify all the non word characters
You can as well use urlencode if needed to encode special characters as url or urldecode to change them to normal characters
Httputility.URLEncode(stringvar)
HttpUtility.URLDecode(stringvar)
Cheers
I don’t want to escape all non word chars (Dots, commas, etc should be excluded from that.
Especially “escaping”/replacing new lines seems to be challenging
Let me know what needs to be removed from the escape characters we can add them as exceptions…\W
takes care of new line characters as well…for all space characters we can use \s
which includes newline character as well
Cheers
I think these are the special characters:
\u2022
\u2023
\u25E6
\u2043
\u2219
@~$^&% and new lines
Please check this…I added few…can add more to the escape characters inside the square brackets
"[^\w,@/\^]"
Hope this helps
Cheers
I tried regex in studio but it doesn’t recognize the characters.
Hi @JenJen
Try this
System.Text.RegularExpressions.Regex.Replace(data, “[^a-z A-Z 0-9]”, “”)
Hope this might help you
I see it is matching what all you neede right?
You dint want @ so it did not match…May I know what difference you are seeing?
Cheers
Seems like this could solve my problem, but I still need the new lines to be replaced How do I add it?
Hi,
Can you try the following expression?
yourString = System.Text.RegularExpressions.Regex.Replace(yourString,"[\u2022\u2023\u25E6\u2043\u2219@~$^&%\r\n]","")
Regards,
Fits for the special characters but doesn’t replace/recognize new lines…
Hi,
In my environment, it replaces newline with blank as the following. How did you check it?
Regards,
I restarted Studio… Seems it works now
Thank you very much to you all!
That helped me to understand Regex a bit better
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.