Reputation: 3848
I have the below RegEx to match email address
[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\.[a-zA-Z]{2,4}
AM trying to escape the characters as below but am still getting java compilation error. Could someone please help me to escape characters in the above RegEx?
String pattern = "\\[-0-9a-zA-Z\\.\\+_\\]\\+@\\[-0-9a-zA-Z\\.\\+_\\]+\\\.\\[a-zA-Z\\]\\{2,4\\}";
Upvotes: 3
Views: 273
Reputation: 4887
The escaped regex is:
"[-0-9a-zA-Z.+_]+@[-0-9a-zA-Z.+_]+\\.[a-zA-Z]{2,4}"
Upvotes: 6