try the following attach code.
what it does:
- match the php string
- verify that before this string there not exists a </a>(close of the anchor tag) but also an start tag before closing one!
Main Topics
Browse All TopicsThis is driving me crazy. I'm looking for a regular expression to match the string "php", so long as it's not within an anchor tag (One of the attribute values) or between the start and closing tag. Consider the following string:
You can read more about the preg_replace() function at the PHP website <a href="http://php.net">PHP<
Only the first "PHP" should match. Nothing inside of "<a href="http://php.net">PHP<
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
(?!php[^(<a)]*<\/a>)php
This is black magic! I hope someone would elaborate on how the 'accepted solution'-expression works.
Questions:
1) In the manual the negative lookahead always precedes some expression to be matched. How can you start with a (negative) lookahead?
2) My testings show no difference if I omit the first 'php' inside the lookahead group. What does it do?
Thanks in advance!
Business Accounts
Answer for Membership
by: quincydudePosted on 2009-03-16 at 19:21:42ID: 23904233
something liek this? ][pP][a-zA -Z0-9\s="' ]*>$/
/^<[a-zA-Z0-9\s="']*[pP][hH