I am facing some issues when copy paste the fancy texts and emojis in a textarea,
Like π and π ΅π °π ½π ²π ππ ΄ππ π Άπ ΄π ½π ΄ππ °ππ Ύπ
I have removed the emojis with following code:
e.content.replace(/([\u2700-\u27BF]|[\uE000-\uF8FF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDFFF]|[\u2011-\u26FF]|\uD83E[\uDD10-\uDDFF])/g, '')
Also wanted to remove the special fonts and fancy texts as well, but not finding a way.
is there any way around for this, like i did for the emojis.
ECMAScript 6 regex solution to match the squared letters is
.replace(/[\u{1F170}-\u{1F189}]+/gu, '')
To also match math and punctuation symbols, you can use the following ECMAScript 2018+ compliant regex:
.replace(/[\u{1F170}-\u{1F189}\p{P}\p{S}]+/gu, '')
The u
flag is required to make \u{XXXX}
notation and \p{X}
Unicode categories work.
Pattern details
\u{1F170}-\u{1F189}
- squared letters\p{P}
- punctuation proper\p{S}
- math symbols.