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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:15:20+00:00 2026-06-01T17:15:20+00:00

I am trying to combine 2 regular expressions into 1 with the OR operator:

  • 0

I am trying to combine 2 regular expressions into 1 with the OR operator: |

I have one that checks for match of a letter followed by 8 digits:

Regex.IsMatch(s, "^[A-Z]\d{8}$")

I have another that checks for simply 9 digits:

Regex.IsMatch(s, "^\d{9}$")

Now, Instead of doing:

If Not Regex.IsMatch(s, "^[A-Z]\d{8}$") AndAlso
   Not Regex.IsMatch(s, "^\d{9}$") Then 
    ...
End If

I thought I could simply do:

If Not Regex.IsMatch(s, "^[A-Z]\d{8}|\d{9}$") Then
    ...
End If

Apparently I am not combining the two correctly and apparently I am horrible at regular expressions. Any help would be much appreciated.

And for those wondering, I did take a glance at How to combine 2 conditions and more in regex and I am still scratching my head.

  • 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-01T17:15:22+00:00Added an answer on June 1, 2026 at 5:15 pm

    How about using ^[A-Z0-9]\d{8}$ ?

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

Sidebar

Related Questions

I'm trying to combine 2 different regex with the same names into one and
I'm trying to combine multiple JSON objects into a single one in PHP. I'm
I'm trying to combine the following three media queries into one: @media only screen
I'm trying to combine images in my app into one file and write it
I'm trying to combine the following expressions into a single expression: item => item.sub,
I am trying to combine the following two functions into one portable function: void
I am trying to combine two images into one. This is the code I
I'm trying to combine two photos into one image (think a body with a
im trying to combine two images into a single image. unfortunately this has to
I'm trying to combine multiple files in multiple input directories into a single file,

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.