Check out example codes for "use regex in if statement java". It will help you in understanding the concepts better.

Code Example 1

Pattern p = Pattern.compile("a*b");
 Matcher m = p.matcher("aaaaab");
 boolean b = m.matches();

Learn ReactJs, React Native from akashmittal.com