Repair RegExp issue

Search result is error, because of searchPattern has a problem.It need reset in next loop.
see：http://stackoverflow.com/questions/1520800/why-regexp-with-global-flag-in-javascript-give-wrong-results