RegEx to remove carriage returns between

tags

前端 未结 7 599
臣服心动
臣服心动 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:38

    Regular expressions are singularly unsuitable to deal with "balanced parentheses" kinds of problems, even though people persist in trying to shoehorn them there (and some implementations -- I'm thinking of very recent perl releases, for example -- try to cooperate with this widespread misconception by extending and stretching "regular expressions" well beyond the CS definition thereof;-).

    If you don't have to deal with nesting, it's comfortably doable in a two-pass approach -- grab each paragraph with e.g.

    .*?

    (possibly with parentheses for grouping), then perform the substitution within each paragraph thus identified.

提交回复
热议问题