Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect "stylized" text?

I was wondering if there was a way to detect if a text is "stylized", like these:

ʇxǝʇ uʍop-ǝp!sdn

ⓣⓔⓧⓣ ⓢⓣⓨⓛⓔ

TRANSMITTING

I͇̜̦̦͇̬ͥ͆̀͠'̵̖̠͉̞͓̯̋̑̾̎̽̐ͫͣm̡̠͚̌̽̊̕͢ ̲̰̠̦̝̥̏͋̄̒ͯ̎̄̅̂͝b̷̛̻̎ͬ̚e̵͍̪̯̺̘̣̩̪̭ͨ̇̈̄̌̃̋̉͘h̶̖̮̦ͯͫ̂ͥ̍ͯ̌́͆͞i̸͙͙̖̹̳̝̭̱͗ͤ̌͢n̰͇̟̪̹̭͎͔͐̃ͧ͋ͥ̉d̵̬̰͌̆ͪ͆̔ͯͩ̈́͜ ͚͎͎̽͌̆̒ͬ̀̕y̵͇̰ͧ͊̈́͛͊̓o̤̳̍͌̉ͪ͒u̹͉̝̲̥ͮ̄͟͡

can regex be used to detect those?

(also, sorry if there's a word for those text, I don't know how they're called and I can't find it anywhere)

like image 273
Blü Avatar asked Aug 25 '15 15:08

Blü


1 Answers

Those are actually special characters, not stylized text, and you can filter them with a regex like this:

var myText = "abc ⓣⓔⓧⓣ ʇxǝʇ uʍop-ǝp!sdn";
var findSpecial = myText.replace(/[\w\s]/g, ""); // \w is for word chars (letters and numbers) and \s for space; g is for general search (all ocurrences) to replace all regular chars and leave the specials
if (findSpecial != "") { 
    alert("Text has special char(s): " + findSpecial);
} else {
    alert("Text has no special chars.");
}

In this example, the alert will be: Text has special char(s): ⓣⓔⓧⓣʇǝʇʍ-ǝ!

like image 153
Matheus Almeida Avatar answered Oct 19 '22 04:10

Matheus Almeida



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!