Problème expressions régulières
Salut !
Je comprend plus rien, j'ai une méthode qui me retourne le premier groupe trouvé lors d'un match d'une expression régulière :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
public static String contains(String pattern, String s) {
System.out.println(s);
Pattern pat = Pattern.compile(pattern);
Matcher mat = pat.matcher(s);
if (mat.matches()) {
System.out.println("match");
return (mat.group(mat.groupCount()));
} else {
System.out.println("don't match");
return new String("");
}
} |
J'ai longtemps cherché avant de poster, pour savoir si je ne me trompai pas dans mon expression, mais je l'ai testée avec RegexSR (super bien fait au passage) et elle fonctionne... Donc ca doit venir du code...
Voici le texte que je cherche à identifier...
Code:
1 2 3 4 5 6 7 8 9 10
| {
ref_count = 0x01 (001);
entity_id = 0x22 (034);
tx_seg_cnf_reqd = KAL_FALSE;
tx_sfn = 0x00 (000);
nw_bmc_start_sfn = 0x00 (000);
nw_bmc_repeat_period = 0x00 (000);
size = 0xa6 (166);
mui = 0xffffffff (-01);
} |
Et voici les regex que j'ai testé :
Code:
1 2
| .*entity_id = 0x(\w+)
.*entity_id = 0x([A-Fa-f0-9]+) |
Elles fonctionnent sous RegexSR mais pas dans mon code (pourtant je protège bien les "\")
Si vous avez une idée !!
Merki !
+++
Ju