RegEx for Removing Non-Ascii Chars Except Certain Whitespaces
Ender Nafi Elekcioglu
endernafi at keehuna.com
Wed Jan 29 10:00:07 EST 2014
Hi all,
I’m a little embarrassed to ask this question for two reasons:
1. I should have known sufficient regex, every coder should.
2. I should have found the answer online, every coder should.
But apparently I couldn’t and I’m struggling for quite a time; please, excuse my ignorance.
I need a RegEx for the below substitution;
Input:
(everybody-should-know-this and this”/‘
Output:
everybody-should-know-this and this
The statement should clear all whitespaces and non-ascii chars except dash and space.
Here is my current code:
_replace space with “nqpSPACEqpn” in tParams
_replace “-“ with “nqpDASHqpn” in tParams
_put replaceText(tParams, “\W”, “”) into tParams
_replace “nqpSPACEqpn” with space in tParams
_replace “ nqpDASHqpn” with “-" in tParams
I’m sure it can be done with a single line of code something like
_put replaceText(tParams, “*** regEx excluding space and dash here ***”, “”) into tParams
Thanks for any help…
Best,
~ Ender
More information about the use-livecode
mailing list