mardi 11 août 2015

Java regex using Pattern and Matcher

I am trying to use matcher as an expression to find time stamps in my list of strings. Ex (" [00:00:00.000] ") There are white spaces before and after the time stamp

I checked my regex online and it say it is correct but will not work with my java. It just returns false.

String word = " [00:00:00.000] ";
Pattern pattern = Pattern.compile("^\\s[[0-9:.]*]\\s");
Matcher matcher = pattern.matcher(word);
    if(matcher.matches()){
        //Do Stuff
    else
        //Do other Stuff

Aucun commentaire:

Enregistrer un commentaire