Reputation: 633
Is there anyway to pick up back-references?
var name = "HELLO WORLD"
var patt = /\S+\s(.+)/;
alert(name.match(patt));
This is just a simple example to get every word after the first.
But, if I alert $1
, nothing pops up and I'm not sure why. I'd appreciate any help!
Upvotes: 0
Views: 1299
Reputation: 633
Just a quick solution to this if anyone is actually looking for this.
You can use RegExp.$X
where X
is the digit of the reference you seek. match
returns an array as well, which you can use to see whether things matched as well as the backreferences in the following indices.
Upvotes: 2