birdiestremph
asked on
weird java regex stuff
CODE:
System.out.println("4.5.2" .matches(" ([0-9]*(\\ .)*)*"));
System.out.println(("mozil la 4.5.2".split("([0-9]*(\\.) *)*"))[1]) ;
Pattern p = Pattern.compile("([0-9]*(\ \.)*)*");
Matcher m = p.matcher("mozilla 4.5.2");
boolean ffVersion = m.find();
if(ffVersion)
{
System.out.println(m.start (0));
System.out.println(m.end(0 ));
}
OUTPUT:
true
m
0
0
So ... it is matching the pattern when i use match(), however the split is splitting as if its delimeter is "", and the matcher isnt finding the pattern at all ...
Any suggestions?
System.out.println("4.5.2"
System.out.println(("mozil
Pattern p = Pattern.compile("([0-9]*(\
Matcher m = p.matcher("mozilla 4.5.2");
boolean ffVersion = m.find();
if(ffVersion)
{
System.out.println(m.start
System.out.println(m.end(0
}
OUTPUT:
true
m
0
0
So ... it is matching the pattern when i use match(), however the split is splitting as if its delimeter is "", and the matcher isnt finding the pattern at all ...
Any suggestions?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:-)
Your pattern will of course match "1234567890" but maybe that's no bad thing ...
Your pattern will of course match "1234567890" but maybe that's no bad thing ...
ASKER
that wasn't quite what i needed, but using the plus made my realize that by putting a * after everything i do is going to match anything. This is what i used instead - "([0-9]+\\.*)+"