> I've tried to pipe paragraphs of a troff document to fmt but I
> have problems with the correct regular expression. My first attempt
> "/^\.[A-Z]++.*\n(^[^]*)*\n^\.[A-Z]++.*\n/" matches only any second
> paragraph because the expression is overlapping. Does anyone have a nice
> idea to match troff parapgraphs?

it's not easy (maybe not possible?) to do what you're doing unless you
can unambiguously find the start and end of paragraphs (e.g. between ^\.PP and 
^$),
in which case you can use something like:

,x/^\.PP/.,/^$/|fmt

for other cases, i suppose it might be nice to have non-greedy matching,
in which case you could do something like:
,x/^\.[A-Z][A-Z].*\n(.*\n)*?\.[A-Z][A-Z]\n/
russ: how easy do you think it would be to put non-greedy matching into
the acme/sam regexp engine?

PS. ++ means exactly the same as +

Reply via email to