I need a regular expression to distinguish two similar words

paddycobbett
paddycobbett used Ask the Experts™
on
Hi, I can't track down some annoying popup in my javascript code. Can someone provide me with a regular expression to match the word "alert" but which does NOT match szalert.

so:

alert('debug 1'); // match!
szalert('debug 1'); // should NOT match

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
/(^|\W)alert/i

Open in new window


HTH,
Dan

Author

Commented:
Awesome that did it thanks!

Commented:
You're welcome. Glad I could help!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial