Cyb3r
Well-known member
So another regex I'm searching for.
Regex to remove all [ img ] bbcode not enclosing a valid url?
Sample:
Code:this is random post .. and [img] random appear without an image. random message then.. [/img] close tag appear
Try this for open tag:
Code:
/\[img\](?!((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?))/i
And this for closing tag:
Code:
/(?!((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?))\[\/img\]/i
don't check "Save Changes" until you make sure all results are valid. It hasn't been tested.