0
How do i understand this pattern?
String line= "this order was placed for QT3000! OK?" Pattern r = Pattern.compile( "(.*)\\d+(.*)"); Macher m = r.matcher(line);
1 ответ
+ 1
"(.*)\\d+(.*)" is regex (regular expression), mean
(.*) - () catch . chars * zero or more
\\d+ - before \d digits +one or more
(.*) - catch chars after it
store regex to regex object Pattern
apply it to line and store result to Matcher object
in this case it take (...QT300) 0 (! OK?) because .* gets maximum possible chars before some digit 0