Please give me some help with preg_replace regex I have this html <a title="Timberland Earthkeepers tv commercial" href="http://www.adsneeze.com/clothing-footwear/timberland-earthkeepers-tv-commercial"> <img width="300" src="http://www.adsneeze.com/files/media-front/Timberland-Earthkeepers-ad.jpg"/> </a> The main idea of advertisement is that if you help the nature, the nature ... more -> <a title="Timberland Earthkeepers tv commercial" href="http://www.adsneeze.com/clothing-footwear/timberland-earthkeepers-tv-commercial">Timberland Earthkeepers tv commercial</a> <div class="feedflare"> <a href="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?a=CXhlKtszp50:4hHyLndkL4w:yIl2AUoC8zA"> <img border="0" src="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?d=yIl2AUoC8zA"/> </a> <a href="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?a=CXhlKtszp50:4hHyLndkL4w:F7zBnMyn0Lo"> <img border="0" src="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?i=CXhlKtszp50:4hHyLndkL4w:F7zBnMyn0Lo"/> </a> </div> <p> <a href="http://feedads.g.doubleclick.net/~a/DoZCMoSsD67yAdsBepwwwwfo5M/0/da"> <img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~a/DoZCMwwwwsBep7d4ITfo5M/0/di"/> </a> <br/> <a href="http://feedads.g.doubleclick.net/~a/DoZCMowwww7d4ITfo5M/1/da"> <img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~a/DoZqwqwqAdsBep7d4ITfo5M/1/di"/> </a> </p> <img height="1" width="1" src="http://feeds2.feedburner.com/~r/AdSneeze-Ads/~4/CXhlKtszp50"/> Code (markup): I want to remove <a href="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?a=CXhlKtszp50:4hHyLndkL4w:yIl2AUoC8zA"> <img border="0" src="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?d=yIl2AUoC8zA"/> </a> <a href="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?a=CXhlKtszp50:4hHyLndkL4w:F7zBnMyn0Lo"> <img border="0" src="http://feeds2.feedburner.com/~ff/AdSneeze-Ads?i=CXhlKtszp50:4hHyLndkL4w:F7zBnMyn0Lo"/> </a> Code (markup): and <a href="http://feedads.g.doubleclick.net/~a/DoZCMoSsD67yAdsBepwwwwfo5M/0/da"> <img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~a/DoZCMwwwwsBep7d4ITfo5M/0/di"/> </a> <a href="http://feedads.g.doubleclick.net/~a/DoZCMowwww7d4ITfo5M/1/da"> <img border="0" ismap="true" src="http://feedads.g.doubleclick.net/~a/DoZqwqwqAdsBep7d4ITfo5M/1/di"/> </a> Code (markup): . Please help.
Something like this should work: .*(<div class="feedflare">.*<\/div><p>.*<\/p>).* Just take out everything between the div and p tags. Peace,
Where is the best place to learn about the parameters that go into preg_replace. I have looked at the phpmanual site, and it explains the function, but not about the parameters and how it works. Thanks.
. -> represents ANY one character [a-z] -> represents ANY characters from a to z, can also be in the form [A-Z],[0-9],[a-z -_] .* -> will match 0 or more occurrences of any character, can also use [a-z]* etc.. .+ -> will match 1 or more occurrences of any characters, can also use [0-9]+ etc.. [a-z]{2} -> will match only 2 occurrences of characters from a to z [a-z]{2,3} -> will match only 2 to 3 occurrences of characters from a to z ^[a-z][0-9]+ -> ^ acts as an anchor, the beginning must be a one letter from a to z, then any number >1 of numbers. $\.php -> Acts like $, but at the end of a match - in this ex, it will return all php extensions \ -> an escape string, like the $ examples, the following must be escaped: . + * ^ $ {} () if you want to use them as characters and not parameters, to use the \ string, it will also need to be escaped like: \\ Add a parameter in () and it will return that match for you, ex.: ([0-9]{4}), will return any numbers of size 4. The above is true for most languages beside PHP. For PHP, when using a regular expression, they need to be in this format: 'CHARACTER EXPRESSION CHARACTER MODIFIER' Where CHARACTER is something like /| etc.., they just need to match: /[a-z]/ or |[a-z]| EXPRESSION is the regular express itself, [a-z]+ MODIFIER is a modifier to tell the parser what and how to do, examples are here: http://www.phpbuilder.com/manual/en/reference.pcre.pattern.modifiers.php Peace,