What is the result?
A.
Pastel
Enamel
Fresco
Gouache
B.
Pastel
*Enamel
Fresco
*Gouache
C.
Pastel
Enamel
Fresco
Gouache
D.
Pastel
Enamel, Fresco
Gouache
Explanation:
regex
, = ,
\ = masks the following
\s = A whitespace character: [ \t \n \x0B \f \r ]
* = Greedy Quantifier: zero or more times
Delimiter: comma + zero or more whitespace characters
B
public static void main(String[] args) {
String input = “Pastel, *Enamel, *Fresco, *Gouacge”;
Scanner s = new Scanner(input);
s.useDelimiter(“,\\s\\*”);
while (s.hasNext()) {
System.out.println(s.next());
}
}
B
Answer is D
nope it’s B