I have a string of HTML, and would like to replace the values in each `href` attribute on anchors with a modified value at a later time. To do this, I'd like to grab the index into the HTML string that the `href` attribute starts at (and the character it ends at), or perhaps the character in the HTML string that the anchor starts at (and the character it ends at). For example, if I have the string:

```
<html><head></head><body><a href='http://example.com'/></body></html>

```

I'd like to write a method that returns `[34, 51]`, the index of the first character in the `href` and the index of the last. As far as I can tell, JQuery does not give me the index into the original HTML string of the response from a selector. Nor does any other library give me a way to determine this information.

If this is not possible with an existing Javascript library (without building a new parser), is there a library in another language that provides this, (particularly Ruby)?