MatchData
by Željko Filipin
Sapna asked how to extract id from this link.
<a href="MessageDetail.aspx?id=1303&messageToUser=True">
RE: Check Copy Request
</a>
The solution includes using MatchData. I use it rarely, and I always forget how it is used. So, every time I need it, I have to read documentation. I have decided to make a note here, so I could easily find it later.
This is how you can get href attribute of that link. I will assumed that he knows text RE: Check Copy Request
.
ie.link(:text, "RE: Check Copy Request").href
=> "MessageDetail.aspx?id=1303&messageToUser=True"
This will extract 1303.
m = /id=(1303)/.match(ie.link(:text, "RE: Check Copy Request").href)
=> #<matchdata :0x2d147b8>
m[1]
=> "1303"