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);

15th May 2020, 12:27 PM
abdul kaiyoom
abdul kaiyoom - avatar
1 Respuesta
+ 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
15th May 2020, 1:19 PM
zemiak