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 436287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:27:44+00:00 2026-05-12T20:27:44+00:00

I want regular expression validator for my telephone field in VB.net. Please see the

  • 0

I want regular expression validator for my telephone field in VB.net. Please see the requirement below:

Telephone format should be (+)xx-(0)xxxx-xxxxxx ext xxxx (Optional) example my number would appear as 44-7966-591739 Screen would be formatted to show +44-(0)7966-591739 ext

Please suggest.

Best Regards,
Yuv

  • 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-12T20:27:45+00:00Added an answer on May 12, 2026 at 8:27 pm

    For validation:
    As bobince points out, you should be flexible with phone numbers because there are so many ways to enter them.

    One simple yet effective way to validate the value is first strip all non-numeric values, then make sure it is at least 11 digits long, and – if you’re limiting to UK numbers – then check it starts with either 0 or 44.

    I can’t be bothered looking up vb.net syntax, but something along the lines of this:

    if Phone.replaceAll('\D','').length < 11
        // Invalid Number
    endif;
    

    (The \D is regex for anything not 0-9.)

    To format a number as requested, assuming you’ve got a relatively fixed input that you want to display to a page, something like this might work:

    replace:

    (\d{2,3})\D*0?\D*(\d{4})\D*(\d{5})\D*(\d*)
    

    with:

    +$1-(0)$2-$3 ext $4
    

    That’s fairly flexible but wont accept any old phone number. It currently required an international code at the start, and I’m not quite sure on the rules of them to know if it’s going to work perfectly, but it might be good enough for what you need.

    An explanation of that regex, in regex comment mode (so it can be used directly as a regex if necessary):

    (?x)        # enable regex comment mode (whitespace ignored, hashes start comments)
    
    # international code:
    (\d{2,3})   # matches 3 or 2 digits; captured to group 1.
    
    # optional 0 with potental spaces dashes or parens:
    \D*         # matches as many non-digits as possible, none required.
    0?          # optionally match a zero
    \D*         # matches as many non-digits as possible, none required.
    
    # main part of number:
    (\d{4})     # match 4 digits; captured to group 2
    \D*         # matches as many non-digits as possible, none required.
    (\d{5})     # match 5 digits; captured to group 3.
    
    # optional prefix:
    \D*         # matches as many non-digits as possible, none required.
    (\d*)       # match as many digits as possible, none required; captured to group 4.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a textbox and a regular expression validator applied to it. I want
I want a regular expression to match valid input into a Tags input field
My application is in ASP.NET 2.0 with C#. I have a regular expression validator
What is the Regular Expression Validator for only Letters and Numbers in asp.net? I
I'm trying to set up a validation expression for an ASP.Net Regular Expression Validator
I want a regular expression to validate an ASP textbox field with the minimum
i want a regular expression to validate string to have only text,operators and these
I want a regular expression that validate a string that allow only numbers and
I want regular expression in ruby on rails which remove all the html tags
I want a regular expression to extract the title from a HTML page. Currently

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.