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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:57:54+00:00 2026-05-19T05:57:54+00:00

I need to build ONE regular expression that can detect ALL the following strings

  • 0

I need to build ONE regular expression that can detect ALL the following strings and ONLY those.

// 'NC_' or 'NG_', can be from 6 to 9 digits after the underscore.
// '.' is static, can be 1 or 2 digits after the '.'
"NC_123456.12" or "NG_123456.12"
// Example: /^N(G|C)_[0-9]{6,9}\.[0-9]{1,2}/


// 'LRG_' is static, can be 1 or more digits after the underscore
"LRG_1234"
// Example: /LRG_[1-9][0-9]*/


// 'UD_' is static, can be 1 or more digits after the underscore
"UD_123456789012"
// Example: /UD_[0-9]+/

So the problem i have is not that i need the regex for finding the strings individually, but that I need ONE regex that can catch ALL the above situations. I don’t know if it’s even possible, but I want to thank everyone beforehand who is willing to try!

  • 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-19T05:57:55+00:00Added an answer on May 19, 2026 at 5:57 am

    You can combine case 2 and three. Also, your regex for case 1 is a bit awkward.

    /N[GC]_[0-9]{6,9}\.[0-9]{1,2}|(LRG|UD)_[0-9]+/
    

    If you use a variant that supports it, you can use

    /N[GC]_\d{6,9}\.\d{1,2}|(LRG|UD)_\d+/
    

    The regex examples you give in the comments are a bit confusing. In case the number after LRG_ must not start with a 0, you have to use the following solution:

    /N[GC]_\d{6,9}\.\d{1,2}|LRG_[1-9]\d*|UD_\d+/
    

    The general principle stands: combine your branches with a |.

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

Sidebar

Related Questions

I need to build one instance of django admin that can be used by
I need a cache that responds to memory pressure like the one build-into ASP.NET.
I need a regular expression that matches APA format references. I currently have this:
I need to build a solution, but exclude one project. How should I do
I need to build a PDF based on FDF. I saw that Adobe has
I need to build a content gathering program that will simply read numbers on
I need to build a scripting interface for my C# program that does system
I need to build my application GUI using HTML/CSS/JavaScript with a C++ backend all
What's the broad math idea behind the calendar if you need to build one
My Questions is Is there any regular expression engine that does Just-In-Time compiling during

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.