Remove character in string javascript

Your first func is almost right. Just remove the 'g' flag which stands for 'global' [edit] and give it some context to spot the second 'r'.

Edit: didn't see it was the second 'r' before so added the '/'. Needs \/ to escape the '/' when using a regEx arg. Thanks for the upvotes but I was wrong so I'll fix and add more detail for people interested in understanding the basics of regEx better but this would work:

mystring.replace[/\/r/, '/']

Now for the excessive explanation:

When reading/writing a regEx pattern think in terms of: followed by followed by

Chủ Đề