Jump to content

trying to replace specific tags and everything inside


aebstract

Recommended Posts

(Didn't realize my other post wasn't in the right section!)

 

$article = eregi_replace("^([[(a-zA-Z0-9.)]]{1,})", "", $article);

 

Trying to get the hang of regex, but I'm failing atm. Need to remove everything from $article that matches  [[anythinggoeshere.anyextension]]  this pattern. The above code doesn't do anything :(

 

If you are trying to learn Regex I suggest you scrap eregi as it is a deprecated function, instead you will want to be using preg_match/replace. Try...

 

preg_replace('#\[[a-z0-9]+\.[a-z0-9]+]#i', '', $article);

 

Alright. Had to add in an extra bracket:

$article = preg_replace('#\[[[a-z0-9]+\.[a-z0-9]+]]#i', '', $article);

 

Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.