Regexp to search/replace only text, not in HTML attribute

后端 未结 6 1314
自闭症患者
自闭症患者 2020-12-11 18:44

I\'m using JavaScript to do some regular expression. Considering I\'m working with well-formed source, and I want to remove any space before[,.] and keep only one space afte

6条回答
  •  半阙折子戏
    2020-12-11 19:34

    Html is not a "regular language", therefore regex is not the optimal tool for parsing it. You might be better suited to use a html parser like this one to get at the attribute and then apply regex to do something with the value.

    Enjoy!

提交回复
热议问题