Test regex

Hello
I do a search on google and I would realize a regex on the page to recover the time to research the top of the page, and Gateling always returns me no found

Environ 4 820 000 résultats (0,22 secondes) 

And my Scala’s code:

import com.excilys.ebi.gatling.core.Predef._
import com.excilys.ebi.gatling.http.Predef._
import com.excilys.ebi.gatling.jdbc.Predef._
import com.excilys.ebi.gatling.http.Headers.Names._
import akka.util.duration._
import bootstrap._
import assertions._
class TestGoogle extends Simulation {
val httpConf = httpConfig
.baseURL(“http://www.google.co.uk”)
.acceptHeader(“image/png,image/;q=0.8,/*;q=0.5”)
.acceptEncodingHeader(“gzip, deflate”)
.acceptLanguageHeader(“en-US,en;q=0.5”)
.connection(“keep-alive”)
.userAgentHeader(“Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:20.0) Gecko/20100101 Firefox/20.0”)
.responseInfoExtractor((response:Response) => {
println("Message from response " )
//+response
Nil
})

val headers_1 = Map(
“Accept” → “”“text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8"”"
)

val scn = scenario(“Scenario Name”)
.exec(http(“request_1”)
.get(“/search”)
.headers(headers_1)
.queryParam(“”“q”“”, “”“twitter”“”)
.check(regex(“”“

(\w+)
”“”))
)
setUp(scn.users(1).protocolConfig(httpConf))
}

PS: sorry for the double post.

First,

is not what being returned in the HTTP response but
(no double quotes).
Then, \w is for matching only word characters (alphanumeric), but the expected result also contains other characters.

The proper regex would be

(.+?)

I agree with Stephane, but, also, a different possible approach, if you are not familiar with regexes, is to use the css selectors.
For exemple, in your case,

Replace

.check(regex("""

(\w+)
"""))

with :
.check(css("#resultStats"))

It’s working, thank a lot