[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: patsubst: multiline text

From: clemens fischer
Subject: Re: patsubst: multiline text
Date: Tue, 07 Sep 2010 23:20:32 +0200
User-agent: tin/1.9.6-20100313 ("Lochruan") (UNIX) (Linux/ (i686))

Eric Blake wrote:

> Thanks for the question.

Thanks for the comprehensive answer  8-)

> Unfortunately, there is admittedly a problem with the current regex
> implementation - it is line based, rather than argument based, so you
> can't really get at newlines directly.  Ultimately, the right fix is
> to add another argument to the various regex macros that lets you set
> flags (line vs. argument, case insensitive, maybe others?) for how a
> given regex will behave.


REG_EXTENDED, but also "multiline" in the sense that "\`"  and "\'"
match at the very start or end of the buffer, respectively, and "^" and
"$" (also?) match after and before embedded line ends (newlines).  Then,
a syntax for matching UTF-8 characters would be nice.

BTW, I couldn't get non-greedy ".+?" or ".+\?" to work, this definitely
deserves fixing, because at times "[^abc]+" doesn't cut it, eg. if
a match for more than one character is needed.

And how about look-forward/look-behind, like in Perl/Python/PCRE?

> On the other hand, since it is all line based, it may be easier than
> you think.  First, note that this inserts spaces on every line:
> patsubst({ml_text}, {^}, {  })

That's funny, I'm already using this for other purposes, but ...

> Then, if you concatenate text before the first line, then a second
> pass can clean up the first line:
> patsubst({-}patsubst({{ml_text}}, {^}, {  }), {^-  }, {- })

... never got this far!  Thanks!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]