Forum Moderators: coopster & phranque

Message Too Old, No Replies

Regex to remove non keyboard chars

         

typomaniac

8:08 pm on May 20, 2022 (gmt 0)

10+ Year Member Top Contributors Of The Month



I've searched high and low for something that would work to no avail but what I need (if it is possible) is a regex that would remove non keyboard items from a string. The other day someone filled out a textarea and copy pasted some hearts from a facebook post and instead of showing the heart it had some characters that were not typical of what you would get by just typing out a message. Either that or I'm going to have to figure on using a WYSIYG textarea rigs but even then there are so many emojis I'm sure someone would try to sneak in on not present. Maybe I need to find out what FB does.

phranque

8:24 pm on May 20, 2022 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i think the ascii character set is what you are looking for.
you might try using a POSIX character class in your regular expression:
https://perldoc.perl.org/perlrecharclass#POSIX-Character-Classes