I need a regular expression to match against all punctuation marks, such as the standard [,!@#$%^&*()], but including international marks like the upside-down Spanish question mark, Chinese periods, etc. My google-fu is coming up short. Does anyone have such a regular expression on hand that’s compatible with Javascript?
Share
If it’s possible for you to use a plugin, there is a plugin for JavaScript: XRegExp Unicode plugins. That adds support for Unicode categories, scripts, and blocks (I personally have only read about it, I never used it).
With this plugin it should be possible to use Unicode categories like
\p{P}as explained at regular-expressions.info.Update:
OK, I tested it, and it seems to work fine.
You need to get the lib from XRegExp and additionally the Unicode Base and Unicode Category plugins (linked above).
The above alerts
true. I included some Spanish and Chinese punctuation in my test string,"?.,;!¡¿。、·".