Downloading all background images as part of load test

Hi all, does K6 not support js regex? Or am I possibly doing something wrong?

    let bg_url_exp = /url\((?!['"]?(?:data):)['"]?([^'"\)]*)['"]?\)/g
    //
    let bg_urls = bg_url_exp.match(body)

Results in

ERRO[0001] TypeError: Object has no member ‘match’

My overall goal is to find all the background-image urls so I can download the images as part of the load test.

I was looking at the selection API and thinking it would be faster to run a RegEx on the HTML body of the get request response.

Since I would need to look at many different nodes I’m not sure where to begin with the selection API if I need to use that to do this.

Any ideas?

It was pointed out to me that I had the JS wrong…

Instead of:

let bg_urls = bg_url_exp.match(body)

It should have been:

let bg_urls = body.match(bg_url_exp)