tags
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
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.