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
Post a Comment