I meant searching for a "bold in a phrase" phrase when it can have various markup in arbitrary places (also, it's not just __, you might have some other valid marker)
But anyway, you can't really use regex here as it's too complicated and error prone for such a frequently needed operation, you need a better mechanism line index or a built in functionality to ignore all markup
look where? it can be any other marker, and it can be nested, and it can be in any position, you can't craft a regex on the fly to capture that, your regex will be longer than the phrase.
Can't you use regex?
_[^_\n\r]+_
edit: I think double underscores are easier, you should be able to use __.+__ and there's no reason to have to avoid matching single_underscore words.