开发者

how to replace multiple occurrences of `&nbsp; and <br>`

开发者 https://www.devze.com 2023-01-10 22:52 出处:网络
how to replace multiple occurrences of &nbsp; and <br> at start of the string with j开发者_如何转开发avascript regex?myString = myString.replace(/^(&nbsp;|<br>)+/, \'\');

how to replace multiple occurrences of &nbsp; and <br> at start of the string with j开发者_如何转开发avascript regex?


myString = myString.replace(/^(&nbsp;|<br>)+/, '');

... where /.../ denotes a regular expression, ^ denotes start of string, ($nbsp;|<br>) denotes "&nbsp; or <br>", and + denotes "one or more occurrence of the previous expression". And then simply replace that full match with an empty string.

0

精彩评论

暂无评论...
验证码 换一张
取 消