: Hi everybody!
:
: I have to read each line from a texte file. Each line looks like this:
: Napoleon | Caesar | Mickey | Lucky Luke
: Next, I have to convert this String to get the following Array:
: name[0]="Napoleon"
: name[1]="Caesar"
: name[2]="Mickey"
: name[3]="Lucky Luke"
:
: Here's the code:
:
: Pattern p = Pattern.compile("Napoleon | Caesar | Mickey | Lucky Luke");
: Matcher m = p.matcher("\\u7C?\\u20\\p{Alnum}*\\u20\\u7C?");
:
: System.out.println("(" + m.groupCount() +" names) ");
:
: \\u7C may represent character | in ASCII(hex)
: \\u20 may represent character SPACE in ASCII(hex)
:
: And the result:
:
: 0 names
:
: Any idea? I'm getting crazy!!!!!
:
: Thanks for your help,
: Zelos
:
hi,
i have absolutely no idea what you are trying to do, the code above makes no sence to me. you compile a regular expression and try if it matches a character sequence, i think you switched this.
for instance the regular expression "[01]+[bB]" matches '0101b' or '0101011100B' etc. so if you like to test whether 'asdf' matches "[01]+[bB]" you will have to code the following
Pattern binNo = Pattern.compile("[01]+[bB]");
Matcher doesMatch = binNo.matcher("01001111b");
Matcher noMatch = binNo.matcher("asdf");
System.out.println("doesMatch: "+doesMatch.matches());
System.out.println("noMatch: "+noMatch.matchers());
greetings
mo