Menu
Question Index
...

What will be the output of the following program?

import java.util.regex.*;

public class SimpleTask {
    public static void main(String[] argv) {
        String pattern = ".*Q[^u]\\d+\\..*";
        String line = "Order QT300. Now!";
        if (Pattern.matches(pattern, line)) {
            System.out.println(line + " matches \"" + pattern + "\"");
        } else {
            System.out.println("NO MATCH");
        }
    }
}


Order QT300. Now!NO MATCH
Order QT300. Now! matches .*Q[^u]\d+\..*
Order QT300. Now! matches ".*Q[^u]\d+\..*"
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Regular Expression

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App