EDIT
heres what i have to do...
Imagine if i have a text with some html tags inside it (it is still a string):
var string = '<p>Hello, my name is Mauricio</p><p>Hi, my name is Patricia</p><p class="warn">Yeah, My name is Carl</p><a href="#"><img src="#" /></a>';
And i want to wrap all the letters "a" with
<span class="ui-match"></span>
but i must not replace anything from the tag, neither what is inside it, neither the class in the
element.
So if I want to wrap all the letters "a" from that string, it would return like that:
<p>Hello, my n<span class="ui-match">a</span>me is M<span class="ui-match">a</span>uricio</p><p>Hi, my n<span class="ui-match">a</span>me is P<span class="ui-match">a</span>trici<span class="ui-match">a</span></p><p class="warn">Ye<span class="ui-match">a</span>h, My n<span class="ui-match">a</span>me is C<span class="ui-match">a</span>rl</p><a href="#"><img src="#" /></a>
all the letters "a" where wrapped with
<span class="ui-match"></span>
, but the link and the paragraph were not.
also this string is comming from a API, so its dynamic... this letter i'm searching is dynamic, so it can be "a" or "abc"... it must not be case sensitive
thanks