java - Need help with regular expression when only one number changes in string -
how check in java regular expression if string matches
monday ptnumber operating mode
where number ( after pt ) has concrete value 0,1,...99,.. - integer? mondaypt , operating mode hardcoded number can change in string.
this extract number.
string input ="monday pt23 operating mode"; pattern p = pattern.compile("monday pt([0-9]+) operating mode"); matcher m = p.matcher(input); boolean found = m.find(); if (found) { string number = m.group(1); system.out.println(number); }
Comments
Post a Comment