Index: branches/REL1_18/phase3/resources/jquery/jquery.highlightText.js |
— | — | @@ -24,8 +24,9 @@ |
25 | 25 | // non latin characters can make regex think a new word has begun: do not use \b |
26 | 26 | // http://stackoverflow.com/questions/3787072/regex-wordwrap-with-utf8-characters-in-js |
27 | 27 | // look for an occurence of our pattern and store the starting position |
28 | | - var pos = node.data.search( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) ); |
29 | | - if ( pos >= 0 ) { |
| 28 | + var match = node.data.match( new RegExp( "(^|\\s)" + $.escapeRE( pat ), "i" ) ); |
| 29 | + if ( match ) { |
| 30 | + var pos = match.index + match[1].length; // include length of any matched spaces |
30 | 31 | // create the span wrapper for the matched text |
31 | 32 | var spannode = document.createElement( 'span' ); |
32 | 33 | spannode.className = 'highlight'; |