Regexp matching across multiple lines?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Martin Fabian

Regexp matching across multiple lines?

Post by Martin Fabian »

I want to convert output from one app into inout of another. This involves replacing thingst like

#tag1 {
t1
t2
t3
}
#tag2 {
t4
t5
}

with something like

newtag1 (this and that)
newtag2 (something) t4 t5

So I tried to regexpmatch for #tag[[:digit:]] {.*} but this wont find anything since . doesn'tmatch the newlines.
I've tried lots of other regexps, such as #tag{{:digit:]] {[^{}]} but again (and always) the non-matching of newline is a problem.
Note that there can be any number of lines like t1 t2 t3 above, I don't know in advance how many, that's why I need regexp matching.
And, I want to eventually write a macro that does all of the replacing in one go.

There's gotta be a way to select across multiple lines with regexps.
Alan Bellows

RE: Regexp matching across multiple lines?

Post by Alan Bellows »

From TextPad's help file:

"\n - A new line character, for matching expressions that span line boundaries. This cannot be followed by operators '*', '+' or {}."

...so, it looks like TextPad's regexps wimp out for multiple-line matches. The other operator that matches newlines, [[:space:]], appears to be limited in the same way.

It appears, however, that I found a way to accomplish this with a macro without too much difficulty... if you want details on that just let me know.

Alan Bellows
Software Developer, Epixtech
Post Reply