LogoReturn to Home RegEx
Integrations
All integrations
AWS API
AWS Lambda
DynamoDB
Oracle
Redshift
Snowflake
GraphQL
Supabase
Twilio
Azure Blob Storage
Slack
SendGrid
Generic HTTP API
AWS S3
Stripe
Microsoft SQL
Salesforce
PostgreSQL
MySQL
MongoDB
HubSpot
Google Sheets
Google BigQuery
Firebase
Airtable
Integrations
About UI Bakery
Log in
Request UI Bakery demo
RegEx library
Email regex C#
Phone number regex C#
IP address regex C#
Date regex C#
URL regex C#
Numbers only regex (digits only) C#
UUID regex C#
Regex match words C#
ZIP code regex C#
GUID regex C#
Password regex C#
HTML regex C#
SSN regex C#
XML regex C#
Mac address regex C#
Street address regex C#

URL regex C#

URL regular expressions can be used to verify if a string has a valid URL format as well as to extract an URL from a string.

Discover UI Bakery – an intuitive visual internal tools builder. Try it now!
JavaScript
Python
Java
C#
PHP

URL regex that starts with HTTP or HTTPS

HTTP and HTTPS URLs that start with protocol can be validated using the following regular expression

new Regex("^https?:\\/\\/(?:www\\.)?[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$")
Test it!
/^https?:\/\/(?:www\.)?[[email protected]:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/

True

False

Enter a text in the input above to see the result

Example code in C#:

using System.Text.RegularExpressions;
using System.Linq;
using System;
                    
public class Program
{
    public static void Main()
    {
        // Validate URL
        Regex validateDateRegex = new Regex("^https?:\\/\\/(?:www\\.)?[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$");
        Console.WriteLine(validateDateRegex.IsMatch("https://uibakery.io"));  // prints True
        
        // Extract URL from a string
        Regex extractDateRegex = new Regex("https?:\\/\\/(?:www\\.)?[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)");
        string [] extracted = extractDateRegex.Matches("You can view more details at https://uibakery.io or just ping via email.")
            .Cast<Match>()
            .Select(m => m.Value) 
            .ToArray(); 
        Console.WriteLine(String.Join(",", extracted)); // prints https://uibakery.io
    }
}

URL regex that doesn’t start with HTTP or HTTPS

The regular expression to validate URL without protocol is very similar:

new Regex("^[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$")
Test it!
/^[[email protected]:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$/

True

False

Enter a text in the input above to see the result

Example code in C#:

using System.Text.RegularExpressions;
using System.Linq;
using System;
                    
public class Program
{
    public static void Main()
    {
        // Validate URL without protocol
        Regex validateDateRegex = new Regex("^[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)$");
        Console.WriteLine(validateDateRegex.IsMatch("uibakery.io/contact"));  // prints True
        
        // Extract URL without protocol from a string
        Regex extractDateRegex = new Regex("[[email protected]:%._\\+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6}\\b(?:[-a-zA-Z0-9()@:%_\\+.~#?&\\/=]*)");
        string [] extracted = extractDateRegex.Matches("You can view more details at uibakery.io or just ping via email.")
            .Cast<Match>()
            .Select(m => m.Value) 
            .ToArray(); 
        Console.WriteLine(String.Join(",", extracted)); // prints uibakery.io
    }
}
Test it!

True

False

Enter a text in the input above to see the result

Notes on URL validation

The above-mentioned regular expressions only cover the most commonly used types of URLs with domain names. If you have some more complex cases you might need a different solution.

Create an internal tool with UI Bakery

Discover UI Bakery – an intuitive visual internal tools builder.

Try it now