Tuesday, 27 August 2013

Syntax issue with match method

Syntax issue with match method

I want to match whatever word is after ">. This is my example text, and
text to match.
<a href="http://www.foo.bar">example_text (a)</a>
Text to grab:
example_text
Here's my code:
$page_html = Nokogiri::HTML.parse($browser.html)
$holder =
$page_html.xpath('/html/body/div[2]/div[5]/div/table/tbody/tr[4]/td/a')
$user = $holder.match('(?<=\"\>)\w*')
And my error:
bot.rb:19: syntax error, unexpected tIDENTIFIER, expecting keyword_end
$user = $holder.match('(?<=\"\>)\w*')
^
I'm guessing the reason is the quotes interfering.

No comments:

Post a Comment