Sunday, October 16, 2022

Replace all string text between certain characters or symbols

Replace/remove everything inside [] including []:

str.replace(/\[(.+?)\]/g, '')

Replace all text inside [] and leave []:

str.replace(/\[(.+?)\]/g, '[]')

https://stackoverflow.com/questions/14438198/replacing-text-in-body

https://stackoverflow.com/questions/39208444/regex-ignoring-text-between-quotes-html5-attribute-filtering

https://www.codegrepper.com/code-examples/javascript/how+to+exclude+a+specific+tag+name+from+a+javascript+query+search

No comments:

Post a Comment