PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I'm finally getting around to tackling REGEX.... Of all the things I've learned about PHP, REGEX was never on the top of my list. Anyway -- I got this little snippet of code to work fine -- basically, I wanted it to remove the whole string including the comment marks. Then I added the extra characters $%#^ etc. and can't get it to work. Does somebody know how I would change this REGEX to replace the entire $String?
$string = "<!--THIS TEXT I WA#$%^@NT OUT OF HERE-->JHGFJTHFHT";
$clean_string = preg_replace("/<!--їa-z0-9]\s+-->/i", "", $string);
echo $clean_string;
Feyd is the King of REGEX. I've seen him come up with REGEX for things I never though possible. It makes me wonder if he's using REGEX coach or something like that....
I don't know of any great tutorials on regular expression, as they are fairly complex to begin with. I can recommend getting the regex bible: Mastering Regular Expressions (O'Reilly Associates)
I learned regex mostly through experimenation, but since getting the bible, I grew quite a bit in my understanding and limitations on more advanced bits like lookbacks..