8
I was reading the documentation to properly develop a mask and save without it.
However I came across this doubt of methods replace and replaceAll for my string.
What is the difference between the two, apparently both serve the same purpose.
8
I was reading the documentation to properly develop a mask and save without it.
However I came across this doubt of methods replace and replaceAll for my string.
What is the difference between the two, apparently both serve the same purpose.
10
Yes, both serve the same purpose. The replace() replaces all occurrences of a character or a sequence of char in a string, while the replaceAll() does the same based on a regular expression pattern.
replace uses replaceAll until, according to source code.
Browser other questions tagged java string regex
You are not signed in. Login or sign up in order to post.
The difference is that the former uses a sequence of chars to make the substitution, the latter uses regex. Both are for the same purpose, only changes that.
– user28595
@diegofm less bad so there is no danger to use one or the other
– Daniel Gentil