ok here it is, i thought i would put it out to everyone to see what others come back with, since mine is just a big messy loop.

I want to be able to highlight using ctrl-r (reverse) a substring of a main string.
The mainstring well have BURKO codes (ctrl-b,ctrl-u,ctrl-k) but NOT ctrl-r (these are already stripped out) in it so its any text with anything in it except for ctrl-r
The substring well be present in the mainstring BUT well not include BURKO codes (its been stripped)
I predict the likely hood of multiple occurances of the substring being present almost nill, first instance only need be worried about, unless you feel so inclined to locate everyone, if its no hardship.

I need an identifier that when passed the mainstring and the substring returns the mainstring with the start and end of the substring marked with ctrl-r

Error trapping is not needed for things like ctrl-r in the mainstring, a simple $remove well strip them out anyway, and checking if substring exists, since I can vouch for the contents of the two input values.

examples
//echo $markup(this is an example string,s an exam)
this is an example string

//echo $markup(8this is a11n example str7ing,s an exam)
8this is a11n example str7ing

//echo $markup(8this is a11n example str7ing,s an exam)
8this is a11n example str7ing

Background info : this is being used in an ON TEXT from channel chatter, the channel text is being stripped and certian key phrases (some of them dynamic based on other message content or nickname) are being scanned for in the text, if one is located, it is wanted to be highlighted in the original UNstripped text using reverse ctrl-r.


----------
ADVANCED POINT to look out for If u can do it, if not dont worry....
When a ctrl-o (ordinary) is in the mainstring this well halt the ctrl-r (reverse), if its possable to detect any ctrl-o's inside the substring area of the mainstring, it would be good to place a ctrl-r following them.

example
//echo $markup(this is an example string,s an exam)
this is an example string

likely hood of this is expected to be extremly low
----------


** im able to do this, have done infact, but its messy, it uses loops, and i think its prone to mistakes. **

Just wanting to see what others might come up with, see other peoples aproches to it, maybe some whizz has a regex solution even?