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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:47:32+00:00 2026-06-04T08:47:32+00:00

I was trying to validate a company name in a web application and had

  • 0

I was trying to validate a company name in a web application and had this regex pattern

^[a-zA-Z_'\\s,;.-0-9]{1,100}$

The above pattern will reject the value 10004 Estates Limited

But if I bring forward 0-9 so the pattern becomes

^[a-zA-Z0-9_'\\s,;.-]{1,100}$

then it works. Am new to regex and patterns, but I know I should be using more of it, so I want to be clear on this. 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-04T08:47:34+00:00Added an answer on June 4, 2026 at 8:47 am

    - is a special character in character classes and thus .-0-9 is ambiguous and probably gets the meaning . to 0 and - and 9, so essentially the characters ./09-.

    To include a hyphen-minus in a character class you’d either have to escape it or place it at the start or end of the character class (which is what you’re doing in the second regex, maybe by accident).

    Edited to add: Above guess seems to be correct, at least for .NET’s regex engine:

    PS> [char[]](32..127) -match '[a-zA-Z_''\s,;.-0-9]'
    
    '
    ,
    -
    .
    /
    0
    9
    ;
    A
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to validate a value against a regex to check if the number
I was trying to validate an XML signature. The validation according to this tutorial
I’m trying to validate input by using egrep and regex.Here is the line from
i am trying to validate a custom expression. This expression contains the follow conditions:
I am trying to validate a list of object on Struts2. Suppose you had
I'm trying to validate this sitemap file . When I validate it inside my
I'm trying to validate this XML document: <?xml version=1.0?> <CONTACTS> <CONTACT CONTACT_NUM = 1>
Trying to validate an Xcode project. First time around, it went fine; this time
When trying to validate my site, I get the following error: Line 188, column
While trying to validate my forms i get the following error: Expected a {

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.