Regular Expression to match two separate phrases

Madean picture Madean · Jun 12, 2012 · Viewed 12.7k times · Source

I am looking for a regular expression that can ensure two phrases showing up on a webpage at the same time.

The two phrases I need to ensure on the web are Current QPS (last 10s, ignored 0) and Average Latency (last 100 queries)

The webpage looks like (The query time would be different, but text won't change):

Query Statistics

Average QPS 25.3673   
Average Latency 0.1002   
Average Latency (last 100 queries) 0.0834   # Match this one, ignore output-0,0834
Average Search Latency 0.0555   
Average Docsum Latency 0.0330   
Sampling period 3133524.9570   
Current QPS (last 10s, ignored 0) 24.8000  # Also match this one, ignore output 24.8000 
Peak QPS 170.9000   
Number of requests 79717858   
Number of queries 79489080 

I am able to match each phrase on the website, but not the two phrases together. How can I make my tool ignore the content between the two phrases?

P.S. I am not programming in any language here, the regex will be put into a tool that accepts regex.

Answer

vergenzt picture vergenzt · Jun 12, 2012

If you can be sure that they will appear in that order, if at all, then this should work:

(<query 1>).*(<query 2>)

E.g.

(Average Latency \(last \d+ queries\)).*(Current QPS \(last \d+s, ignored \d+\))

You may need to check that the . operator matches newlines in your tool.