Im a completely retarded person when it comes to creating regex patterns!
I want to check a users input, and allow certain urls, so here I have half of a pattern I have put together - Well it is actually the whole bit, but im missing bits and parts to actually call it a regex.
So with errors:
if (!preg_match('|^http://|https://([www])+[.]+(-azAZ09)+[.]+[azAZ]{2,6}?$|i', $post_gl_url))
{
////
}
I want to allow:
http:// and https://
www ({3?})
. a dot
domain name
. a dot
com/us/dk/pl etcetc
And then it should be possible after this to add a querystring, so this should be allowed too, but the pattern shouldnt create an error if theres no querystring appended:
?id=10&-+_ (allowed in query-string)
How in he.. do I put it together?
So I end up with these being valid urls, ieg:
http://www.domain.com
https://www.domain.com
http://www.domain.nl?id=23&city=big
http://www.domain.dk/seo/friendly/url
Lost in the regex world!
All the best,
Klemme