Matcher Pattern number : Digit Number « Regular Expressions « Java

Matcher Pattern number


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String args[]) {

    Pattern p = Pattern.compile("\\d");
    Matcher m1 = p.matcher("55");
    Matcher m2 = p.matcher("fdshfdgdfh");

    System.out.println(m1.pattern() == m2.pattern());
    // return true


Related examples in the same category

1.Check if given string is a number (digits only)
2.Check if given string is numeric (-+0..9(.)0...9)
3.Check if given string is number with dot separator and two decimals
4.Match number
5.Match a single digit
6.reduce To Alpha Numerics with Regex