mardi 3 octobre 2017

regex isMatch returns false

Original regex: [v]\d+?\.\d

Captures the "v{N}.{n}" in strings where {N}/{n} is only a number. I try in code (java) but returns false.

Code:

  String content = "En este texto hay un documento v4.6.pdf";

  String pattern = "[v]\\d+?\\.\\d";

  boolean isMatch = Pattern.matches(pattern, content);
  System.out.println("The text contains 'v{N}.{n}'? " + isMatch);

Console:

The text contains 'v{N}.{n}'? false

Aucun commentaire:

Enregistrer un commentaire