RegEx to remove carriage returns between

tags

前端 未结 7 600
臣服心动
臣服心动 2021-01-07 07:57

I\'ve stumped myself trying to figure out how to remove carriage returns that occur between

tags. (Technically I need to replace them with spaces, not

7条回答
  •  爱一瞬间的悲伤
    2021-01-07 08:40

    A single-regex solution is basically impossible here. If you absolutely insist on not using an HTML parser, and you can count on your input being well-formed and predictable then you can write a simple lexer that will do the job (and I can provide sample code) -- but it's still not a very good idea :)

    For reference:

    • Why shouldn't I parse XML or XHTML with a regex?
    • How can I parse HTML in my language of choice?

提交回复
热议问题