I have a text which is like ->
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.
Now, I want to highlight some part of this text, so I need to know the start and end offsets of the string.
Let's say
it to make a
This is the text I want to highlight, so I need the offset of this text; so far I tried using the following logic
var startoffset = $scope.original_doc_content.indexOf("it to make a ");
var endoffset = startoffset + string.length;
Now my issue is happening if it to make a
is present 2 times in the given text: if I want to highlight or want to take the second one and if it's present before the 2nd one then it gives me the 1st ones offset and not the second one which I require. So how can I resolve this?