Mahir Mahir - 11 months ago 105
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
function, I call

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

However, matches is returning as null

Answer Source

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/));