Given the following arbitary string:
"This is page one, This is page two, and this is page two, and this is page three."
I am highlighting (dragging my cursor over the text and selecting) a random sub-string; for this example I am highlighting the second occurrence of the term "page two".
I get this highlighted text using:
var text = window.getSelection().toString();
I now need to determine what the start and end index of the highlighted term within the text.
The string and highlighted term is arbitrary - there is no pattern to selection.