5 min read
2026-01-28
Before final use, make sure that the replacement does not affect unnecessary fragments. Especially when working with short strings.
A good tool will show you how many matches have been found. Check the number before replacing.
Mass replacement is irreversible. Keep a copy of the original text in case of an error.
Regular expressions allow you to:
Replace dates from DD.MM.YYYY format to YYYY-MM-DD
Remove HTML tags
Extract and reformat data
Changing "cat" will also change "kitten" and "hammer". Add spaces or use word boundaries in regex (`\\b`).
When making multiple substitutions, the order is important. Each subsequent replacement works with the result of the previous one.
Replacement without taking into account nested matches
Loss of formatting when replaced in HTML
Changing code or data that should not change
See also: Text comparison, Data extraction