Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RegEx for all letters (including Chinese, Greek, etc.)

I need a regex that also matches Chinese, Greek, Russian, ... letters. What I basically want to do is remove punctuation and numbers.

Until now I removed punctuation and numbers "manually" but that does not seem to be very consistent.

Another thing I have tried is

/[\p{L}]/

but that is not supported by Mozilla (I use this in a Firefox extension).

like image 643
slosd Avatar asked Jul 04 '09 20:07

slosd


1 Answers

Have you given XRegExp and the Unicode plugin a try/look?

<script src="xregexp.js"></script>
<script src="xregexp-unicode.js"></script>
<script>
    var unicodeWord = XRegExp("^\\p{L}+$");
    alert(unicodeWord.test("Ниндзя")); // -> true
</script>
like image 100
Jonathan Lonowski Avatar answered Sep 29 '22 02:09

Jonathan Lonowski