Replace All
Tag With Space In Javascript
Having trouble with very simple thing, How to properly replace all < br> and in the string with the empty space? This is what I'm trying to use, but I'm receiving
Solution 1:
You can achieve that using this:
str = str.replace(/<br\s*\/?>/gi,' ');This will match:
<brmatches the characters<brliterally (case insensitive)\s*match any white space character[\r\n\t\f ]- Quantifier:
*Between zero and unlimited times, as many times as possible, giving back as needed [greedy] \/?matches the character/literally- Quantifier:
?Between zero and one time, as many times as possible, giving back as needed [greedy] >matches the characters>literallygmodifier: global. All matches (don't return on first match)imodifier: insensitive. Case insensitive match (ignores case of[a-zA-Z])
SNIPPET BELOW
let str = "This<br />sentence<br>output<BR/>will<Br/>have<BR>0 br";
str = str.replace(/<br\s*\/?>/gi, ' ');
console.log(str)
Post a Comment for "Replace All
Tag With Space In Javascript"