Useful regular expression that every developer should know

What is regular expression?

A regular expression is a pattern that is used to match character combinations in strings.

The regular expression is the most complicated thing if we don’t understand the basic of it. It is important to know the basics of it. Throughout the software development career, it will be hard to find someone who never used regular expression.

But if we know the basic then it is really easy and smart things to do. Following are some really useful regular expression that we think every developer should know:

Replace various symbols that are not math symbols, currency signs, or combining characters.

inputString.replaceAll("\\p{So}+", "");

Replace all alphanumeric chanarcters.

inputString.replaceAll("^[a-zA-Z0-9]*$", "");

Useful links for about regular expression:
http://www.regular-expressions.info/unicode.html

Share