.contains() / .replace()
Searching and replacing.
Syntax
s.contains("x") // s.replace(old, new)Description
contains tells whether a substring exists (true/false). replace swaps matches with a new one (returns a new string).
Example
Loading editor…
Expected output
true 2024/01
When to use?
Search boxes, text sanitization.