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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:23:02+00:00 2026-05-15T23:23:02+00:00

I need to write a regular expression for an ‘option symbol’ for my company

  • 0

I need to write a regular expression for an ‘option symbol’ for my company so we can validate these symbols across our site.

An option symbol is composed of two parts:

Part1         Part2
_ _ _ _ _ _ | _ _ _ _ _ _ _ _ _ 

I can write a regular expression for Part2 as it is fairly simple.

However, Part1 (the first 6 character positions) can be a little complicated.

It boils down to:

  • Part1 must be {6} characters in length total.
  • There must be between {1,4} alpha characters in the first positions.
  • After that, there can optionally be {1} numeric character.
  • Finally, the rest of the characters remaining must be spaces, so Part1 totals to 6 characters.

The problem I’m having is that the number of spaces is variable based on the number of characters before it. This makes me think it isn’t easily representable by a regular language.

How can I avoid brute-forcing it like so:

([A-Za-z]{1}[0-9]{1}[ ]{4}|
[A-Za-z]{2}[0-9]{1}[ ]{3}|
[A-Za-z]{3}[0-9]{1}[ ]{2}|
[A-Za-z]{4}[0-9]{1}[ ]{1}|
[A-Za-z]{1}[ ]{5}|
[A-Za-z]{2}[ ]{4}|
[A-Za-z]{3}[ ]{3}|
[A-Za-z]{4}[ ]{2}|
[A-Za-z]{5}[ ]{1})

Here are some example option symbols (remember, ignore everything beyond the first 6 characters):

F     123456P12345678
CMG   123456P12345678
AAPL  123456P12345678
GOOG1 123456C12345678
F5    123456C12345678
  • 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-15T23:23:03+00:00Added an answer on May 15, 2026 at 11:23 pm

    You can use a lookbehind assertion:

    ^[A-Za-z]{1,4}\d? +\b(?<=^.{6})
    

    Explanation:

    ^: Match the start of the line or string (depending on whether you set the option RegexOptions.Multiline or not).

    [A-Za-z]{1,4}\d? +: Match 1 to 4 alpha characters and an optional digit, followed by at least one space

    \b: Assert that we are now at a word boundary (i.e., that the next character is alphanumeric)

    (?<=^.{6}): Assert that the above match is exactly six characters long.

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

Sidebar

Related Questions

No related questions found

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.