Created
January 27, 2012 00:35
-
-
Save thenbrent/1686151 to your computer and use it in GitHub Desktop.
Regex to match a given term only when it does not appear within certain HTML tags (ie. a) or WP shortcodes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pattern = '/([^a-zA-Z0-9-_>\[])(' . preg_quote( $given_term ) . ')([^a-zA-Z0-9-_<\]])(?!([^<]*)(\>|\<\/a|\]|<\/h\d\>))/i' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment