I looked through the documentation of the URI class in ruby but couldn't find a way to extract the anchor (HTML) from the instance. For example, in
http://example.com/index.php?q=something#anchor
I would like to get the anchor
text. Trivial solution is to manipulate the text with regular expressions but if there is some method for it, then it's much better.
The URI
module provides a fragment
attribute. e.g:
>> uri = URI("http://example.com/index.php?q=something#anchor")
>> uri.fragment
=> "anchor"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With