What is the difference between the replace () and replaceAll () methods?

8

I was reading the documentation to properly develop a mask and save without it.

However, I came across this question about methods replace and replaceAll for my string .

What's the difference between the two, apparently both serve the same purpose.

    
asked by anonymous 03.04.2017 / 14:53

1 answer

10

Yes, both serve the same purpose. replace() replaces all occurrences of a character or a string of char in a string , while replaceAll() does the same based on a regular expression pattern.

    
03.04.2017 / 14:57