Regular expression to match two separate phrases

I am looking for a regular expression that can simultaneously display two phrases on a web page.

The two phrases I need to provide on the Internet are Current QPS (last 10s, ignored 0)andAverage Latency (last 100 queries)

The web page looks like (the request time will be different, but the text will not 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 can match each phrase on a website, but not two phrases. How can I make my tool ignore content between two phrases?

PS I do not program in any language here, the regular expression will be placed in a tool that accepts a regular expression.

+5
source share
4 answers

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

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

.

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

, . .

+5

, , .

/($regex1.*?$regex2|$regex2.*?$regex1)/
+1

This may depend on the tool you use - in particular, how it handles multiple lines.

You can try the following:

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

This should work

(?im)^(Average\s+Latency\s+\(last\s+100\s+queries\)|Current\s+QPS\s+\(last\s+10s,\s+ignored\s+0\)).+
0
source

All Articles