Languages
[Edit]
EN

Java - i18n equivalent for \w in regular expression (i18l word characters matching)

5 points
Created by:
Emrys-Li
580

In this short article, we would like to show how to improve \w rule to match i18n word characters in Java.

\w is equals to [a-zA-Z_0-9]

To match i18n word characters we should use:

 

Practical example

Edit

In this section, the below program iterates through text finding matched i18n characters organized in words.

On line printed in output represents a single matched word.

Output:

Note: above rule can have problems with some scripts/alphabets, e.g. Hebrew.

References

Edit
  1. Predefined Character Classes - Oracle Docs 
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join