Mahir Mahir - 1 month ago 21
Javascript Question

Capturing regex expression in Phantom.js returning null

I'm trying to scrape from the following website

Specifically, I'm trying to obtain the player's draft position, aka "X overall" which appears in the line


1st round (3rd pick, 3rd overall)


Within my
page.open()
function, I call

var rawText = page.plainText;
var regExp = /pick, ([\d]+)\w\w overall/;
var matches = regExp.exec(rawText);
console.log(matches);


However, matches is returning as null

Answer

Your regex seems fine (the match below works) so there must be something wrong with the string you're matching against.

console.log("1st round (3rd pick, 3rd overall)".match(/pick, ([\d]+)\w\w overall/));