Using JavaScript's replace() method with global switch on a variable -


I am not able to understand how it will work for me even after I have not been able to understand it.

What I want to do is take a string that is assigned to a value, and it is used as a match string for all matches.

  var replacement = 'i'; Var text = 'tieiam'; Text = text Location (substitution, ''); // 'pyium' text = text Location (/ time / g, ''); // 'Team'  

How do I use them together ??

What do you want to use RegExp object:

  Text = text.replace (new RegExp (replacement, 'g'), '');  


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -