I am working on patterns right now and have a couple of simple questions. I got the following piece of code from the book I am using to check on a URL and would appreciate a better explanation of the different pieces of it. Ignore the underlining.
$pattern = "([url]http://[/url])?([[:space:]]+)([[:alnum:].,-_?/&=])";
I understand that we are telling it that data we will be gathering can start with the [url]http://[/url] but that this is optional, that it can not be followed by a space, and that it may be followed by any number, letter, slash, quetion mark, ampersand, and equals sign. My questions are as follows:
First of all, what exactly do the question (+) marks mean. There was no formal explanation in my book and it would help me to remember to use them if I knew what they meant.
Second, wouldn't it be better to have something like the following to make sure someone uses a valid URL:
$pattern = "([url]http://[/url])?([[:space:]]+)([[:alnum:].,-_?/&=]).([:alnum:]+)";
I'm sure there much better ways to check for a URL and if any one can give me their version along with a brief explanation I would greatly appreciate it.
Thanks!