RegEx for Removing Non-Ascii Chars Except Certain Whitespaces

John Craig john at splash21.com
Wed Jan 29 10:49:10 EST 2014


When you say 'non-ascii' do you mean non alphanumeric?

if tData contains your string then..
put replaceText(tData, "[^[:alnum:]- ]", "")

will replace anything that isn't alphanumeric, dash or space with blnk.

:)



On 29/01/2014 15:00, Ender Nafi Elekcioglu wrote:
> 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
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list