How do I remove all special characters from a string?

Get help using Construct 2

Post » Sun Jun 19, 2016 4:21 pm

I'm not familiar with Regex but I fear I may need to learn quickly for this. I was hoping I could accomplish this with replace(), another expression, or a feature of a text(input) box that disallows special characters.

I know:

replace(src, find, rep)
Find all occurrences of find in src and replace them with rep.

But can you have multiple options for find? With no success I tried:
replace(Entry.Text, "/|?", "")
replace(Entry.Text, "/"|"?", "")
replace(Entry.Text, "/""?", "")
replace(Entry.Text, "/"&"?", "")

I know I could layer them:
replace(replace(Entry.Text, "?", ""), "/", "")
But that seems tedious if I need to do all special characters —> [email protected]#$%^&*()_+-=[]{}|\;':",.<>/?

Purpose is for passing text via AJAX to php file (to submit in mysql table). I remove special characters in the php script but want to avoid any errors in passing the values to the php script. I'm pretty sure that at least = ? & would disrupt the URL. I could research to narrow down eliminating only the ones that would disrupt but would rather be safe and eliminate them all ... as who really needs any of those special characters in their name.
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473

Post » Sun Jun 19, 2016 4:30 pm

Found a simple Regex example and modified, does this encompass everything I need:

RegexReplace(Entry.Text, "\W", "g", "")

I don't understand much Regex at all—most of the Regex examples/tutorials were over my head atm but— finally found a message board post that helped after sifting through a bunch I couldn't grasp.
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473


Return to How do I....?

Who is online

Users browsing this forum: Syazanie Amirin and 42 guests