$text = preg_replace("~(\[url(?U)(=.*)?\])?((http|https|ftp|ftps)://)([а-яА-Яa-zA-Z.\/0-9-+_?=&%\#;]+)(\[\/url\])?~siu", '[url$2]$3$5[/url]', $text);