RE: [Grinder-use] Repost : Regular expressions with Struts action errors --> Sorry for the terrible
Distributed load testing framework - Java, Jython, or Clojure scripts.
Brought to you by:
philipa
From: <duv...@ya...> - 2005-07-27 18:55:55
|
This seems to work : regex = re.compile(r'<span class="error">[\s*\S+\s*]+ </span>', re.M) \T, --- duv...@ya... wrote: > > Joe, > > If you look at the bootom of the initial mail you have the python script & 2 HTML's. > > OK > my expression is composed of 3 parts of interrest that one can find in the HTML page : > 1°. <span class="error"> > 2°. Differenciating part > 3°. </span> > > The opening & closing tags (1 & 3) I can match. > The middle part, is either : > _ Some text --> meaning there is has been a business exception : \S+ > _ An unknown number of white space characters : \s* > in python regular expression "parlence". > > According to O'Reilly's book (pocket reference and Learning python) the re.M means that the > parsing is done not against the whole text as a String (see below how I extract the html file > content) but more in a line per line way. > > Using : > regex = re.compile(r'<span class="error">\S+</span>', re.M) > Does not react for both files (no matches) > > Using > regex = re.compile(r'<span class="error">.+</span>', re.M) > Does react for both files (matches both) > > Cheers, > > \T, > > > --- Joe Heck <Joe...@do...> wrote: > > > Without seeing the test data, it's a little hard to understand what > > isn't working. If the <span> tags are split across a newline, that could > > be a reason why its failing to match. You need to compile your RE with > > re.M as well to take care of that scenario. > > > > Do you expect that there will NEVER be a newline or carriage return > > between the span tags? > > > > Sorry if I'm focusing on the wrong thing here - it's something that has > > bit me in the past. As a diagnostic tool, I recommend matching the very > > basic component and building up your regular expressions iteratively to > > find out where it fails. That process has worked exceptionally well for > > me. > > > > -joe > > > > -----Original Message----- > > From: gri...@li... > > [mailto:gri...@li...] On Behalf Of > > duv...@ya... > > Sent: Wednesday, July 27, 2005 10:35 AM > > To: gri...@li... > > Subject: [Grinder-use] Repost : Regular expressions with Struts action > > errors --> Sorry for the terrible formatting > > > > > > Dear, > > > > First of all, my apologies for the previous post which lost its > > foramtting. > > > > I am using the grinder and I need to validate no Action errors have been > > put on the response I > > fetch. There is a company wide style sheet so every body is using the > > same <span > > class="error"></span> > > I am basically struggeling with the following needs. > > If there is anything but : > > space, tabs, line feeds, carriage return > > in between the two tags, the page contains a mistake. > > I have tried dozens of regular expressions but they always seems to > > fails in some scenario. > > I came to the logical answer to be : > > regex = re.compile(r'<span class="error">\S+</span>', re.I) > > > > IMHO this mean that the text I will inspect for matches will trigger if > > there is any occurrence of > > a non-white space character. It however does not behave the way I expect > > it to. > > Environment is jython (instead of pure python). > > Incidently I tested against a gnu-python 2.2.1 and the result is the > > same :( > > > > > > Kind regards, > > > > > > \T, > > > > > > > > > > Any fool can write code that a computer can understand. > Good programmers write code that humans can understand. > Martin Fowler > T. : +32 (0)2 742 05 94 > M. : +32 (0)497 44 68 12 > > > ------------------------------------------------------- > SF.Net email is sponsored by: Discover Easy Linux Migration Strategies > from IBM. Find simple to follow Roadmaps, straightforward articles, > informative Webcasts and more! Get everything you need to get up to > speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click > _______________________________________________ > Grinder-use mailing list > Gri...@li... > https://lists.sourceforge.net/lists/listinfo/grinder-use > Any fool can write code that a computer can understand. Good programmers write code that humans can understand. Martin Fowler T. : +32 (0)2 742 05 94 M. : +32 (0)497 44 68 12 |