go to previous page   go to home page  
String manyPets = "Ant, Bat, Cat,,,,," ;
String[] pieces = manyPets.split( ", *" , 0 );

Answer:

String[] pieces = { "Ant", "Bat", "Cat" };

End of Chapter

You have reached the End of the Chapter. Here is a list of topics you may wish to review.

  1. matches()
  2. whitespace in regular expressions
  3. Checking user input
  4. Testing GUI input
  5. Escaping characters in strings
  6. Escaping metacharacters
  7. replaceAll()
  8. Capture groups with replaceAll()
  9. replaceFirst()
  10. split()

You have reached the end of the chapter.

go to previous page   go to home page