I am faced with a text that goes like this ->
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
My goal now is to emphasize a specific part of this text, so I need to determine the start and end offsets of the string.
Let's say
it to make a
This is the portion of the text I wish to highlight, thus needing the offset of this particular section; my attempt at achieving this involved the following approach:
var startoffset = $scope.original_doc_content.indexOf("it to make a ");
var endoffset = startoffset + string.length;
The issue arises if it to make a
appears twice within the given text: in such cases, when I aim to highlight or select the second occurrence, the logic gives me the offset of the first one instead of the desired second one. How can I go about resolving this dilemma?