0

I know you can do something like this:

var str = "Microsoft has the largest capital reserves of any tech company. Microsoft is located in California.";
str = str.replace(/microsoft/gi, "Apple");

and you'd get the following: Apple has the largest capital reserves of any tech company. Apple is located in California.

How can I use the global case insensitive to change a string like 07/08/2011 to 07082011?

I tried variations of str.replace(///gi, "") with no luck.

3 Answers 3

2

Try this:

var input = "07/08/2011";
var output = input.replace(/\//g,""); //output 07082011
Sign up to request clarification or add additional context in comments.

Comments

0

try using escape character (back slash):

str.replace(/\//gi, "")

Comments

0
str = str.replace(/\//g,'')

this will remove all forward slashes

1 Comment

is unnecessary the "i" in this case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.