in reply to character offset to word offset
Given a character offset, you can use substr to pick out the part of the string that comes before the word in question. Given that string, you can count the words, perhaps by splitting it. Given the substr that comes after the character offset, you know the word is at the front. You can use a regular expression to pull out that word. Then you can get its length to see what of the string comes after it. That should give you enough info to know where to put the asterisks before you print the result.
|
|---|