Shared Java Regular expression syntax and examples below
1, matching verification-Verify that the email is correct
public static void Main (string[] args) {
//string
str = "service@xsoftlab.net" to be validated;
Mailbox validation Rule
String regEx = [a-za-z_]{1,}[0-9]{0,}@ ([a-za-z0-9]-*) {1,}\\.) {1,3} [a-za-z\\-] {1,} ";
Compile regular expression pattern
= Pattern.compile (regEx);
Ignores case writing/pattern
Pat = pattern.compile (regEx, pattern.case_insensitive);
Matcher Matcher = Pattern.matcher (str);
Whether the string matches the regular expression
Boolean rs = Matcher.matches ();
System.out.println (RS);
2. Query character or string in string
public static void Main (string[] args) {
//string
str = "baike.xsoftlab.net" to be validated;
Regular expression rule
String regEx = "baike.*";
Compile regular expression pattern
= Pattern.compile (regEx);
Ignores case writing/pattern
Pat = pattern.compile (regEx, pattern.case_insensitive);
Matcher Matcher = Pattern.matcher (str);
Find out if there is a character/string in the string that matches the regular expression
Boolean rs = Matcher.find ();
System.out.println (RS);
3, regular expression of the common
4, Regular expression syntax
About Java Regular expression syntax and examples for everyone to introduce this, I hope to help you learn.