Welcome to DevShed Forums, mike224.
1) You put your entire expression inside the brackets. That tells the engine to match the characters in
any order, not just the order you want.
You only want the brackets around the characters that will appear between the single-quotes:
Code:
'/\[URL=\'[:.\/\-\d\w\?]\'\]/'
2) The question mark is a special character, so when it's not in a character class (the characters between the square brackets), it needs to be escaped with a backslash like the other special characters.
3) You need to also put a quantifier after the character class, because by itself the character class will only match a single character. In this case you may want to use the "+" which means to match 1 or more characters.
Code:
'/\[URL=\'[:\.\/\-\d\w\?&=]+\'\]/'
However, I would recommend using a negative character class instead, so you don't have to specify every character that might appear in a URL. The "^" as the first character in a character class indicates that any character not in the class will be matched, so we want to match any character that is not a single quote:
Code:
'/\[URL=\'[^\']+\'\]/'
Useful references:
http://www.php.net/manual/en/pcre.pattern.php
http://www.regular-expressions.info/reference.html