mardi 30 août 2016

Alternative representation for characters in REGEX

Why can't get the same behavior when i build a Pattern from a literal regular expression than when i read the regular expression from a file?

String regex = "(?xi)(title)[\\.:;](.*) \043 Title property";
Pattern pattern = Pattern.compile(regex);
System.out.println(pattern);
// will print:

(?xi)(title)[.:;](.*) # Title property

wish is fine. But when i read the regular expression from a file to try to build the same Pattern the '\043' isn't replaced. Why? Any help?

The main reason is that I'm trying to avoid the use of the literal '#' character symbol and to use and alternate representation of it, because other conflicts.

Aucun commentaire:

Enregistrer un commentaire