Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regular expression to match French and German characters

Tags:

java

regex

I am parsing the request parameters to find any vulnerable characters to prevent XSS threats. Our web application supports both French and German languages other than English. I am using the following regular expression to achieve this, but it fails to handle French and German

^[a-zA-Z0-9\r\n\\-=\\*\\.\\?;,+\\/:&_ %@#]*$

Any suggestions on this is highly appreciated

like image 999
Faizal Basheer Avatar asked Apr 20 '11 07:04

Faizal Basheer


People also ask

Does regex work for other languages?

Short answer: yes.

How do you match expressions in regex?

To match a character having special meaning in regex, you need to use a escape sequence prefix with a backslash ( \ ). E.g., \. matches "." ; regex \+ matches "+" ; and regex \( matches "(" . You also need to use regex \\ to match "\" (back-slash).

Does regex match anything?

Matching a Single Character Using Regex ' dot character in a regular expression matches a single character without regard to what character it is. The matched character can be an alphabet, a number or, any special character.


1 Answers

\p{L} will match any unicode character that is a letter.

like image 76
Joachim Sauer Avatar answered Nov 15 '22 13:11

Joachim Sauer