Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1063669
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:49:02+00:00 2026-05-16T18:49:02+00:00

I’ve been struggling with finding a suitable solution :- I need an regex expression

  • 0

I’ve been struggling with finding a suitable solution :-

I need an regex expression that will match all UK phone numbers and mobile phones.

So far this one appears to cover most of the UK numbers:

^0\d{2,4}[ -]{1}[\d]{3}[\d -]{1}[\d -]{1}[\d]{1,4}$

However mobile numbers do not work with this regex expression or phone-numbers written in a single solid block such as 01234567890.

Could anyone help me create the required regex expression?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:49:03+00:00Added an answer on May 16, 2026 at 6:49 pm

    Would this regex do?

    //  using System.Text.RegularExpressions;
    
    /// <summary>
    ///  Regular expression built for C# on: Wed, Sep 8, 2010, 06:38:28 
    ///  Using Expresso Version: 3.0.2766, http://www.ultrapico.com
    ///  
    ///  A description of the regular expression:
    ///  
    ///  [1]: A numbered capture group. [\+44], zero or one repetitions
    ///      \+44
    ///          Literal +
    ///          44
    ///  [2]: A numbered capture group. [\s+], zero or one repetitions
    ///      Whitespace, one or more repetitions
    ///  [3]: A numbered capture group. [\(?]
    ///      Literal (, zero or one repetitions
    ///  [area_code]: A named capture group. [(\d{1,5}|\d{4}\s+?\d{1,2})]
    ///      [4]: A numbered capture group. [\d{1,5}|\d{4}\s+?\d{1,2}]
    ///          Select from 2 alternatives
    ///              Any digit, between 1 and 5 repetitions
    ///              \d{4}\s+?\d{1,2}
    ///                  Any digit, exactly 4 repetitions
    ///                  Whitespace, one or more repetitions, as few as possible
    ///                  Any digit, between 1 and 2 repetitions
    ///  [5]: A numbered capture group. [\)?]
    ///      Literal ), zero or one repetitions
    ///  [6]: A numbered capture group. [\s+|-], zero or one repetitions
    ///      Select from 2 alternatives
    ///          Whitespace, one or more repetitions
    ///          -
    ///  [tel_no]: A named capture group. [(\d{1,4}(\s+|-)?\d{1,4}|(\d{6}))]
    ///      [7]: A numbered capture group. [\d{1,4}(\s+|-)?\d{1,4}|(\d{6})]
    ///          Select from 2 alternatives
    ///              \d{1,4}(\s+|-)?\d{1,4}
    ///                  Any digit, between 1 and 4 repetitions
    ///                  [8]: A numbered capture group. [\s+|-], zero or one repetitions
    ///                      Select from 2 alternatives
    ///                          Whitespace, one or more repetitions
    ///                          -
    ///                  Any digit, between 1 and 4 repetitions
    ///              [9]: A numbered capture group. [\d{6}]
    ///                  Any digit, exactly 6 repetitions
    ///  
    ///
    /// </summary>
    public Regex MyRegex = new Regex(
          "(\\+44)?\r\n(\\s+)?\r\n(\\(?)\r\n(?<area_code>(\\d{1,5}|\\d{4}\\s+"+
          "?\\d{1,2}))(\\)?)\r\n(\\s+|-)?\r\n(?<tel_no>\r\n(\\d{1,4}\r\n(\\s+|-"+
          ")?\\d{1,4}\r\n|(\\d{6})\r\n))",
        RegexOptions.IgnoreCase
        | RegexOptions.Singleline
        | RegexOptions.ExplicitCapture
        | RegexOptions.CultureInvariant
        | RegexOptions.IgnorePatternWhitespace
        | RegexOptions.Compiled
        );
    
    
    
    //// Replace the matched text in the InputText using the replacement pattern
    // string result = MyRegex.Replace(InputText,MyRegexReplace);
    
    //// Split the InputText wherever the regex matches
    // string[] results = MyRegex.Split(InputText);
    
    //// Capture the first Match, if any, in the InputText
    // Match m = MyRegex.Match(InputText);
    
    //// Capture all Matches in the InputText
    // MatchCollection ms = MyRegex.Matches(InputText);
    
    //// Test to see if there is a match in the InputText
    // bool IsMatch = MyRegex.IsMatch(InputText);
    
    //// Get the names of all the named and numbered capture groups
    // string[] GroupNames = MyRegex.GetGroupNames();
    
    //// Get the numbers of all the named and numbered capture groups
    // int[] GroupNumbers = MyRegex.GetGroupNumbers();
    

    Notice how the spaces and dashes are optional and can be part of it.. also it is now divided into two capture groups called area_code and tel_no to break it down and easier to extract.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.