Page 1 of 1

Regex removing/replacing before DB in practice...

Posted: Mon Feb 22, 2021 1:43 am
by liveme
Hi,
Looking for to use the regex or equivalent replaceText feature in order to sanitize inputs before saving to DB.

Anyone would know how to succesfully remove several symbols that I can not seem to kick out ?

the following works 90% but fails for those...

Code: Select all

  put replaceText(tFieldText,"[-$&~'#%?!@°,*+=></\(){}]","")  into field "textcleaned" 
failled to remove caracters :
>>> :

Code: Select all

  \    

(both slash are already included, but one does not get removed)
.... beside how would one includes the brackets and the ' " ' symbol ?
>>>

Code: Select all

 ' ['  , ']'  ,' " ' 


Thanks for any help

Re: Regex removing/replacing before DB in practice...

Posted: Mon Feb 22, 2021 10:32 am
by Thierry
Hi liveme,

Code: Select all

Your orignal regex:
[-$&~'#%?!@°,*+=></\(){}             ]

The new one:
[-$&~'#%?!@°,*+=></\(){} \\ [\] \x22 ]
I've added some spaces to draw attention,
please drop them in your code.

\\ will match any \
[\] will match [ and ]
\x22 is the hex value for the double quote

not tested!

HTH,

Thierry

Re: Regex removing/replacing before DB in practice...

Posted: Tue Feb 23, 2021 8:54 am
by liveme
Thanks a lot Thierry for showing me the correct way !
...no problem, I ll test it !
Great great :wink: !

Works perfectly !

Re: Regex removing/replacing before DB in practice...

Posted: Tue Feb 23, 2021 9:05 am
by Thierry
liveme wrote:
Tue Feb 23, 2021 8:54 am
Thanks a lot Thierry for showing me the correct way !
...
You're welcome.

If you find anything wrong or unclear, please let us know...

Regards,

Thierry