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

Re: RegExp, Double Quotes and ^E

On Tue, Feb 20, 2001 at 04:47:11PM +0100, Axel Beckert wrote:
> Hi
> Axel Beckert wrote:
> > [...]
> [results in]
> > DESTINATION="/fnord/"
> There is another little problem: Those double quotes shouldn't be
> there in the last line.

Hi Axel,

the problem is that double quotes may have a special meaning under some
circumstances, e.g. within attributes.  In body tags, it is assumed to
be a normal character, so when read it is replaced by ^E and output
routines revert this change.

> But matching regexps against that strings with doublequotes seems not
> to work (single-backslash quoted double quotes according to the WML
> documentation at engelschall.com):
> 	<subst-in-var val "^\"(.*)\"$" "\\1" />

Hmmm, we should have this discussion on sw-wml-dev, i must explain
some internals here to explain what happens. Basically, some extra
characters are added by mp4h around `val', so you have to write
 	<subst-in-var val "^\003*\"(.*)\"\004*$" "\\1" />

> The debugging output says always ^E instead of double quotes:

Forgot to replace ^E by double quotes in debugging output, will be

> Oh and another BTW: The solution from my last does not work, if values
> go over several lines (in pass 2, so you may use pass 1 to concatenate
> several lines using backslashes)...

The right solution is to use a new <disjoin> function (patch attached).
First try:
   <set-var <disjoin %body>>
Seems to work, but the quotes are still here as explained above.
2nd try:
   <set-var <disjoin <subst-in-string %body "\"" "">>>
But now, it won't work if values are more than 1 word long.
Last try:
   <subst-in-string "=LT=set-var <disjoin
      <subst-in-string %body "\"([^\"]*)\""
             "=LT=compound>\\1=LT=/compound>">>>" "=LT=" "<">

Hey, isn't that nice? ;)
But maybe you should use wml_p3_eperl to parse your conf files, things
would be much easier.

Denis Barbier
WML Maintainer
Website META Language (WML)                www.engelschall.com/sw/wml/
Official Support Mailing List                   sw-wml@engelschall.com
Automated List Manager                       majordomo@engelschall.com