Java String.replaceAll()

The method replaceAll() replaces all occurrences of a String in
another String.

Available Signatures

public String replaceAll(String regex, String replacement)

Example

@Test
public void whenCallReplace_thenCorrect() {
    String s = "I learn Spanish";

    assertEquals("I learn French", s.replaceAll("Spanish", "French"));
}

Next »

« Previous

Leave a Reply

Your email address will not be published.