Pattern: URL

“URL” is one of the patterns that you can select on the Match panel. Use this pattern to make a field match an internet address as you would enter into a web browser’s address bar. You can set the pattern to allow any URL, or to require specific schemes, ports, domains, file paths, parameters, etc.

List of Schemes

Enter the schemes or protocols the URL can use, delimited by semicolons. http;https;ftp allows the most common protocols. If you don't specify any schemes, the field will require the URL to have a scheme but will allow any scheme, including a non-existent one.

If you want to allow URLs like www.regexmagic.com that don't specify a URL scheme then specify the subdomain those URLs should begin with followed by a dot as the scheme. http;https;ftp;www.;ftp. allows URLs with the http, https and ftp protocols on any domain, as well as URLs without a protocol on www. and ftp. subdomains.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Port numbers

A URL can include a port number to connect to a different port than the one normally used by the protocol, e.g. http://www.domain.com:6969

List of Port Numbers

A URL can include a port number to connect to a different port than the one normally used by the protocol, e.g. http://www.domain.com:6969

Type in or paste in the port numbers the URL can use, delimited by semicolons. You can use a hyphen to specify a range of ports. E.g.: 80;1024-65535 allows ports 80 and 1024 through 65535.

If you do not specify any port numbers, all ports from 1 to 65535 will be allowed.

The list of ports is ignored if the field validation mode is set to "none" or "loose". To make the regex actually check the port numbers, set the field validation mode to "average" or "strict".

User Names

URLs can include a user name. It will appear before the domain, delimited by an @ sign. E.g.: http://user@www.domain.com. You can choose if this field should match URLs that include user names or not, or search for specific user names.

List of User Names

Type in or paste in the user names this field should allow, delimited by semicolons.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Password

Choose if the URL can have an embedded password, as in http://user:password@www.domain.com. URLs can only contain a password if they also contain a user name.

This syntax is not commonly used any more. The embedded passwords are plainly visible. Leaving passwords visible is usually not a good idea. RegexMagic still supports it. You may want to search for URLs with embedded passwords and remove the passwords from them.

Domain Names

In a URL like http://www.domain.com, "www.domain.com" is the full domain name. You can restrict it if you're only interested in certain URLs.

List of Domain Names

Type in or paste in the domain names this field should allow, one per line.

This box is a full-featured text editor. You can cut, copy and paste with Ctrl+X, Ctrl+C and Ctrl+V as usual. Press Enter to insert a line break.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Folders

The file referenced by a URL can be in a folder or directory structure, e.g.: http://www.domain.com/folder/subfolder/file.html. You can determine if the URL can include folders, and which ones.

List of Folders or Paths

Type in or paste in the folders or paths allowed in the URL, one per line. If you set the folders choice to "specific paths only", type in path names like "onefolder", "folder/subfolder" and "folder/subfolder/3rdlevel". Only the exact paths you specify will be allowed. Otherwise, type in individual folder names like "folder1", "folder2" and "folder3". The regular expression will allow any combination of these folders, like folder2/folder3/folder1/folder2.

This box is a full-featured text editor. You can cut, copy and paste with Ctrl+X, Ctrl+C and Ctrl+V as usual. Press Enter to insert a line break.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Minimum Folder Depth

The minimum number of folders that the URL should specify. Set to zero to allow URLs without a folder. Set to greater than zero to require a certain folder depth.

For example http://www.domain.com/folder1/subfolder/level3/filename.html has a folder depth of 3. However, if you set Folders to "allow any path", "safe URL characters only", or "basic characters only" (all of which allow dots in folder names) and you set File names to "no file name" then the generated regex will match this URL as if it had a folder depth of 4 with "filename.html" being the 4th folder. Likewise, if you set Folders to "allow any path" and Parameters to "no parameters" then the list of parameters will be included with the final folder.

Maximum Folder Depth

The maximum number of folders that the URL should specify. This number must be equal to or greater than the minimum number of folders and must be greater than zero. Set Folders to "no folders" if you don't want to allow any folders at all.

For example http://www.domain.com/folder1/subfolder/level3/filename.html has a folder depth of 3. However, if you set Folders to "allow any path", "safe URL characters only", or "basic characters only" (all of which allow dots in folder names) and you set File names to "no file name" then the generated regex will match this URL as if it had a folder depth of 4 with "filename.html" being the 4th folder. Likewise, if you set Folders to "allow any path" and Parameters to "no parameters" then the list of parameters will be included with the final folder.

File names

Choose if the URL can or should include a file name, such as http://www.domain.com/filename.ext.

List of File Names or Extensions

Type in or paste in the file names the URL can reference, one per line. If you selected "specific extensions only", enter the extensions, e.g. "html" and "txt".

This box is a full-featured text editor. You can cut, copy and paste with Ctrl+X, Ctrl+C and Ctrl+V as usual. Press Enter to insert a line break.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Optional file name

If you've specified that the URL should include a file name, you can choose whether the filename is optional or mandatory.

Parameters

A URL can include a list of parameters at the end, e.g.: http://www.domain.com/action.php?param1=value1¶m2=value2. You can restrict this field to disallow parameters or to require certain parameters.

List of Parameters

Type in or paste in the parameters that can occur in the URL, one per line.

This box is a full-featured text editor. You can cut, copy and paste with Ctrl+X, Ctrl+C and Ctrl+V as usual. Press Enter to insert a line break.

If the field validation mode is set to "none" or "loose", the list only determines which characters are allowed. To make the regex actually check for the whole list, set the field validation mode to "average" or "strict".

Examples