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.

This example shows how you can use the “URL” pattern to look for URLs. You can find this example as “Pattern: URL” in the RegexMagic library.

  1. Click the New Formula button on the top toolbar to clear out all settings on the Samples, Match, and Action panels.
  2. On the Samples panel, paste in one new sample:
  3. On the Match panel, click the Add First Field button to add field 1.
  4. In the “pattern to match field” drop-down list, select “URL”.

  5. Set the options for the URL pattern as shown in the screen shot.
  6. Set the “field validation mode” to “average”.
  7. On the Regex panel, select “C# (.NET 2.0–4.8 & .NET Core 1.0–3.0)” as your application, turn off free-spacing, and turn off mode modifiers. Click the Generate button, and you’ll get this regular expression:

    Required options: Case insensitive.
    Unused options: Exact spacing; Dot doesn’t match line breaks; ^$ don’t match at line breaks; Numbered capture.

  8. The Samples panel now highlights the URLs our regex matches: