What is the result?

Given:

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class Test {

private static String REGEX = “\\Sto\\S|\\bo\\b”;

private static String INPUT = “Nice to see you,to,be fine.”;

private static String REPLACE =”,”;

public static void main(String[] args) {

Pattern p = Pattern.compile(REGEX);

Matcher m = p.matcher(INPUT);

INPUT = m.replaceAll(REPLACE);

System.out.println(INPUT);

}

}

What is the result?

Given:

import java.util.regex.Matcher;

import java.util.regex.Pattern;

public class Test {

private static String REGEX = “\\Sto\\S|\\bo\\b”;

private static String INPUT = “Nice to see you,to,be fine.”;

private static String REPLACE =”,”;

public static void main(String[] args) {

Pattern p = Pattern.compile(REGEX);

Matcher m = p.matcher(INPUT);

INPUT = m.replaceAll(REPLACE);

System.out.println(INPUT);

}

}

What is the result?

A.
Nice to see you, be fine

B.
Nice, see you, be fine

C.
Nice, see you, to, be fine

D.
Nice, see you, be fine

E.
Nice to see y, u, be fine

Explanation:
The text to is removed (replaced by the empty string).



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Jan

Jan

Nice to see you,be fine.

Google

Google

Here are several of the websites we suggest for our visitors.

gelete

gelete

A

Nice to see you,be fine.