using preg_match and preg_replace

TheCat

New Member
I have two strings like:\[code\]http://localhost/web/\[/code\]and\[code\]http://localhost/web/category/\[/code\]which sometimes become:\[code\]http://localhost/web/2/\[/code\], \[code\]http://localhost/web/3/\[/code\] etc....and\[code\]http://localhost/web/category/2/\[/code\], \[code\]http://localhost/web/category/3/\[/code\] etc...I want to make a verification and:If the link is \[code\]http://localhost/web/\[/code\] it remains the same.If the link is \[code\]http://localhost/web/2/\[/code\] it becomes \[code\]http://localhost/web/\[/code\]If the link is \[code\]http://localhost/web/category/\[/code\] it remains the same.If the link is \[code\]http://localhost/web/category/2/\[/code\] it becomes \[code\]http://localhost/web/category/\[/code\]I guess it should be done using \[code\]preg_replace()\[/code\] and \[code\]preg_match()\[/code\].How can I do it?Thanks.
 
Back
Top