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

  • Home
  • SEARCH
  • 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 7863507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T23:30:09+00:00 2026-06-02T23:30:09+00:00

In A comprehensive regex for phone number validation , the accepted answer has a

  • 0

In A comprehensive regex for phone number validation, the accepted answer has a number of comments. One of the comments, by @jcmcbeth, suggests the following simple regular expression to use to obtain the digits of the telephone number submitted by a user:

string.replace("[^\d+!x]", "")

Immediately following the comment with this suggested regular expression, another questioner asks why the !x part?, which is then answered in the next comment: The !x is there to keep any "x" character from getting stripped.

This makes sense to me, except for the exclamation point !. Looking at documentation for character classes in regular expressions, I do not see that the exclamation point is a special character, and it doesn’t seem to me that the x requires a special character preceding it. Also, from the discussion in the linked question, I do not see any comment indicating that an exclamation point might be part of a telephone number (which would explain its inclusion in the negated character class).

Can someone please explain to me why the exclamation point is present? Thanks.

  • 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-06-02T23:30:11+00:00Added an answer on June 2, 2026 at 11:30 pm

    You’re absolutely right, the x is sufficient. ! just matches a literal !, inside a character class or out. The only place it has any special meaning is when it’s part of negative lookahead or a negative lookbehind.

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

Sidebar

Related Questions

Possible Duplicate: A comprehensive regex for phone number validation Just a simple regex required
Possible Duplicate: A comprehensive regex for phone number validation Greetings, I need to implement
Possible Duplicate: A comprehensive regex for phone number validation How to validate a phone
Possible Duplicate: A comprehensive regex for phone number validation Validate phone number with JavaScript
Possible Duplicate: A comprehensive regex for phone number validation Perhaps a forgiving JavaScript solution
Possible Duplicate: A comprehensive regex for phone number validation I have an unformatted phone
Possible Duplicate: A comprehensive regex for phone number validation i want to validate a
I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it
A fairly comprehensive query of the brain has turned up a thousand and one
Is there a comprehensive Html cleaner/Anti-Xss library for .NET that also has a defined

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.