Menu
Question Index
...

What will be the output of the following program?

import java.util.regex.*;

public class RegTest {
    public static void main(String[] args) {
        String regex = "\\d";
        Pattern pattern = Pattern.compile(regex);
        String input = "Aaaa99MeritCampus4";
        Matcher matcher = pattern.matcher(input);
        matcher.find();
        matcher.find();
        System.out.print(matcher.group());
        matcher.find();
        System.out.println(matcher.group());
    }
}


4
9
99
94
994
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