I'm using the following line of PHP to remove punctuation from strings:
$key = preg_replace("/\p{P}/u", "", $key);
Does anyone know how to do the same thing in Javascript/jQuery?
I know you can use jQuery's replace() like PHP's preg_replace(). I just don't know what regular expression to use.
Something like this :
<script type="text/javascript">
var str = "Some text here ...";
var pattern = /\p{P}/u;
document.write(str.replace(pattern,''));
</script>
Edit :
It seems that Javascript is not PECL compatible, so the p{P} will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With