In brief
replaceAll() returns new text with all matches found replaced according to the specified rule.
Useful to know
To replace all occurrences of a specific text, replaceAll() can accept a text template and a replacement text. The method returns a new string and leaves the original unchanged. When regular expression is required the global flag g. [1]
The example '2026/10/21'.replaceAll('/', '-') gives '2026-10-21'. This is a conditional string conversion, not a date validation. '2026/99/99' would also go through the same replacement, although it is not a calendar date.
In a text search, symbols are seen as a literal sequence. This is often clearer than constructing a regular expression from a user input. You don't need to use regex for every simple replacement.
After the conversion, separately check the meaning of the result. Replacing a comma with a dot, for example, does not automatically decide how to read a number with separators for thousands or with a different local notation.
Sources
For further detail and to check the information: