nerdexam
Oracle

1Z0-851 · Question #20

Given: 11. String test = "Test A. Test B. Test C."; 12. // insert code here 13. String[] result = test.split(regex); Which regular expression, inserted at line 12, correctly splits test into "Test…

The correct answer is E. String regex = "\\.\\s*". See the full explanation below for the reasoning.

Question

Given: 11. String test = "Test A. Test B. Test C."; 12. // insert code here 13. String[] result = test.split(regex); Which regular expression, inserted at line 12, correctly splits test into "Test A", "Test B", and "Test C"?

Options

  • AString regex = "";
  • BString regex = " ";
  • CString regex = ".*";
  • DString regex = "\s";
  • EString regex = "\.\s*";
  • FString regex = "\w[ .] +";

How the community answered

(36 responses)
  • B
    6% (2)
  • C
    11% (4)
  • D
    3% (1)
  • E
    78% (28)
  • F
    3% (1)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice