regex - Regular Expression to Validate Long URLs in PHP -


I'm looking for help in creating a regular expression that validates a long time URL (like a Too long Google Maps address). I'm new to regular expressions and I'm using it in PHP with preg_match ().

I used Expression:

preg_match ('/ ^ (http | https | ftp): \ / \ / ([A-Z0-9] [ A -Z0-9 _-] * (?: [. [A-Z0-9] [A-Z0-9 _-] *) *):? (\ D +)? \ /? / I ', $ Url)

But it does not work for very long URLs. My knowledge of regular expression is almost non-existent, so if there is a simple change that is helpful, do not doubt it.

Here is an example of errors I'm getting:

If the link is basically:

Validation regenerates:

Validate whether it is a valid url:

  $ valid = filter_var ($ Url, FILTER_VALIDATE_URL);  

Inspection requires that if variables are prescribed, obtain them as an associative array and isset () :

 < Code> parse_str (parse_url ($ url, PHP_URL_QUERY), $ get_variables);  

Comments