Mailing list - Entries of 2006


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

Re: [qftestJUI] Problem checking multi-line text with regular expression


  • Subject: Re: [qftestJUI] Problem checking multi-line text with regular expression
  • From: Gregor Schmid <Gregor.Schmid@?.de>
  • Date: 31 May 2006 10:21:02 +0200

Hello Mark,

ahh, the art of regexps... :-)

Rule 24: Don't escape more than is absolutely necessary.

In your example it appears that escaping the '<', '/' and '>'
characters with a '\', which is not necessary for regexps, is actually
causing the problems. The following works for me:

(.|\n)*<body>( |\n|\t)*<p>( |\n|\t)*</p>(  |\n|\t)*</body>(.|\n)*

Best regards,
    Greg


"Michaelis, Mark" <mark.michaelis@?.com> writes:

>    Hello,
> 
> 
> 
>    I would like to test a HTML document to contain nothing but an empty
>    paragraph in its body. Therefore I started experimenting with a
>    regular expression as I don't want the test to break everytime when
>    changes appear in e. g. the head. But I cannot get the regular
>    expression to run. Although I already found a hint by Bastian Bowe
>    (25.7.2005) that newlines are not supported and you should use the
>    workaround (.|\n)* my suggested regular expressions still doesn't
>    work.
> 
> 
> 
>    Here is the original source to check against (just the part between
>    the body-tags):
> 
> 
> 
>      <body>
>        <p>
> 
>        </p>
>      </body>
> 
>    This regular expression works (but does not test the thing I would
>    like to test):
> 
> 
> 
>    (.|\n)*\<p\>(.|\n)*
> 
> 
> 
>    The next step forward already does not work anymore:
> 
> 
> 
>    (.|\n)*\<p\>(.|\n)*\<\/p\>(.|\n)*
> 
>    And of course the final expression I would like does not work, too:
> 
>    (.|\n)*\<body\>( |\n|\t)*\<p\>( |\n|\t)*\<\/p\>(
>    |\n|\t)*\<\/body\>(.|\n)*
> 
>    or
> 
>    (.|\n)*\<body\>[ \n\t]*\<p\>[ \n\t]*\<\/p\>[ \n\t]*\<\/body\>(.|\n)*
> 
>    or
> 
>    (.|\n)*\<body\>[\s\n]*\<p\>[\s\n]*\<\/p\>[\s\n]*\<\/body\>(.|\n)*
> 
> 
> 
>    Any hints are welcome (before I start to write a SUT Script)...
> 
> 
> 
>    Regards,
> 
>    - Mark

-- 
Gregor Schmid                                Gregor.Schmid@?.de
Quality First Software GmbH                     http://www.qfs.de
Tulpenstr. 41                                Tel: +49 8171 919870
DE-82538 Geretsried                          Fax: +49 8171 919876


Videos Downloads Documentation Buy Free Trial