Mahir Mahir - 1 year ago 148
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/));

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download