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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:58:20+00:00 2026-05-31T20:58:20+00:00

How to fix this regex in order to get the mentioned outcome ? regex:

  • 0

How to fix this regex in order to get the mentioned outcome ?

regex: (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[(?:M|V|P)(?:[^\[])*])

string: LCR005B"*ADM-CID"9876R579BDFL789ABC#12345A[4D32FC2B12345A|113002065][Vanydata][M1234567890AB][Panydata]

outcome should be:

  1. 005B
  2. “*ADM-CID”
  3. 9876
  4. R579BDF
  5. L789ABC
  6. #12345A
  7. [4D32FC2B12345A|113002065]
  8. [Vanydata]
  9. [M1234567890AB]
  10. [Panydata]

Later edit:

This currently outputs:

  1. 005B
  2. “*ADM-CID”
  3. 9876
  4. R579BDF
  5. L789ABC
  6. #12345A
  7. [4D32FC2B12345A|113002065]
  8. [Vanydata]
  • 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-31T20:58:22+00:00Added an answer on May 31, 2026 at 8:58 pm

    This is your regex:

    (0(?:[0-9]|[A-F]){3})
    (\"\*?(?:SIA-DCS|ADM-CID|NULL)\")
    (\d{4})
    (R?(?:[0-9]|[A-F])*)
    (L[^#]*)
    (#[^\[]*)
    (\[[^\[]*)
    (\[(?:M|V|P)(?:[^\[])*])
    

    You do have only 8 capturing groups, none is repeated, why do you think this should output 10 groups?

    OK, Because of the (?:M|V|P) of the last group, it would be able to match the content of the 3 last square brackets, but this group is not repeated, so it will match only the first one.

    You have 2 possibilities.

    1. Put a quantifier behind the last group

      (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[(?:M|V|P)(?:[^\[])*])+
      

      or

      (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[(?:M|V|P)(?:[^\[])*]){3}
      

      this will now match the string till the end, but there are still only 8 capturing groups and the content of the last one is now not “[Vanydata]” anymore, its the last match of this group “[Panydata]”

    2. Add two more groups to your regex

      (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[(?:M|V|P)(?:[^\[])*])(\[(?:M|V|P)(?:[^\[])*])(\[(?:M|V|P)(?:[^\[])*])
      

      This does now have 10 capturing groups and the result is as you expected. If the Starting letter of those 3 last groups is always the same for each group you can simplify it to

      (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[V(?:[^\[])*])(\[M(?:[^\[])*])(\[P(?:[^\[])*])
      

      See it here on Regexr

    Update

    You can make something optional by adding a question mark after it

    (0(?:[0-9]|[A-F]){3})(\"\*?(?:SIA-DCS|ADM-CID|NULL)\")(\d{4})(R?(?:[0-9]|[A-F])*)(L[^#]*)(#[^\[]*)(\[[^\[]*)(\[[VMP](?:[^\[])*])?(\[[VMP](?:[^\[])*])?(\[[VMP](?:[^\[])*])?
    

    See it here on Regexr, hovering over the match shows you the content of the capturing groups.

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

Sidebar

Related Questions

How can I fix this? REGEX: //REGEX $match_expression = '/Rt..tt<\/td> <td>(.*)<\/td>/'; preg_match($match_expression,$text,$matches1); $final =
Consider the following: string keywords = (load|save|close); Regex x = new Regex(@\b+keywords+\b); I get
How can I fix this RegEx to optionally capture a file extension? I am
I have this string hey {Bobby|Apple|Peter}, nice to meet you {David} and this regex:
I can't fix this problem on my listview template: i have the error as
How to fix this error? @echo off Setlocal EnableDelayedExpansion REM LINES FOR TEST: REM
How do I fix this so that when php calls $fontcolor and the user
Any ideas how to fix this? UserService.UserServiceClient userServiceClient = new UserServiceClient(); userServiceClient.GetUsersCompleted += new
How do i fix this link in javascript. <a href=javascript:clientGalleryLink(Business)>Link</a> Its missing single quotes
How do I fix this error? error C2668: 'std::_Tree<_Traits>::end' : ambiguous call to overloaded

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.