DEV Community

Cover image for Can I Use replace() method to autoreplace all the chosen strings within a user input box of text type in js?

Can I Use replace() method to autoreplace all the chosen strings within a user input box of text type in js?

S3RG1096 on March 19, 2020

Let's say there is a long-*ss paragraph, and some words in it are issues to copyright, so custom replacements are needed to all strings in p or spa...
Collapse
 
adam_cyclones profile image
Adam Crockett 🌀

Replace can take regex patterns.
This can happen on keyup.

I won't be providing any code sorry, but that's how you would solve it.

Collapse
 
pavelloz profile image
Paweł Kowalski • Edited

Yep, replace with regexp is the way to go.

duck.com is your friend.

Collapse
 
s3rg1096 profile image
S3RG1096

thx!