I can use
var regex = /[$&+,:;=?@#|]/;
if(elem.match(regex)) { // do something
}
to find whether there is any special characters in string in Javascript.
How can I use the similar regular expression in Java?
I have tried:
str.match("\\="); // return false
For example:
String str = "123=456";
I tried to detect “=” in str.
That did not work. What am I doing wrong?
Try this.
EDIT:
matches()checks all the string andfind()finds it in any part of the string.A link:
http://docs.oracle.com/javase/tutorial/essential/regex/index.html