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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:39:51+00:00 2026-06-01T10:39:51+00:00

This question is very similar to an earlier question I asked ( This Question

  • 0

This question is very similar to an earlier question I asked ( This Question ), however I need to change it slightly.

So in the earlier question this string

Berkshire Hathaway Inc (Ticker: BRK; NAICS: 524126, 511130, 335212, 445292, 511110, 442210; Duns: 00-102-4314) Walt Disney Co (Ticker: DIS; NAICS: 713110, 512110, 711211, 515120; Duns: 00-690-4700)

creates 2 matches with these values:

Berkshire Hathaway Inc
Walt Disney Co

Now I want the matches to contain Ticker: XXX or the Company Name with preference going to Ticker: XXX.

So for the example above it would match:

Ticker: BRK
Ticker: DIS

And for this example:

Berkshire Hathaway Inc (NAICS: 524126, 511130, 335212, 445292, 511110, 442210; Duns: 00-102-4314) Walt Disney Co (Ticker: DIS; NAICS: 713110, 512110, 711211, 515120; Duns: 00-690-4700)

The result would be:

Berkshire Hathaway Inc
Ticker: DIS

I guess I just don’t understand the regex solution in the previous question well enough to understand how to modify it to fit this pattern.

The regex is written in c#

By the way the previous regex solution was:

(?!\s*$)(.*?)(?:\([^)]*(?:(?:SIC|NAICS):[^)]*)+\)|$)

which I guess should be changed to this now:

(?!\s*$)(.*?)(?:\([^)]*(?:(?:SIC|NAICS|Duns):[^)]*)+\)|$)

but how do I extract the Ticker: and choose that value over the other value if Ticker exists?

  • 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-01T10:39:53+00:00Added an answer on June 1, 2026 at 10:39 am

    I’m still learning regex, so I’m not sure if you can use conditional logic on groups. As an alternative though, you could modify your regex as follows so that it also captures a group for the ticker if it exists:

    (?!\s*$)(.*?)(?:\((Ticker:[^;]+)?[^)]*(?:(?:SIC|NAICS|Duns):[^)]*)+\)|$)
    

    Then you could do the logic in your c# code. I guess something like this would work:

    Regex regex = new Regex(@"(?!\s*$)(.*?)(?:\((Ticker:[^;]+)?[^)]*(?:(?:SIC|NAICS|Duns):[^)]*)+\)|$)");
    Match match = regex.Match("Berkshire Hathaway Inc (NAICS: 524126, 511130, 335212, 445292, 511110, 442210; Duns: 00-102-4314) Walt Disney Co (Ticker: DIS; NAICS: 713110, 512110, 711211, 515120; Duns: 00-690-4700)");  
    while (match.Success) {
        if (match.Groups[2].Success)
        {
            Console.WriteLine(match.Groups[2].Value);
        }
        else
        {
            Console.WriteLine(match.Groups[1].Value);
        }
        match = match.NextMatch();
    }
    

    Output:

    Berkshire Hathaway Inc 
    Ticker: DIS
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very similar to this question I asked earlier. I am hoping to
This question is very similar to the question asked here so I hope this
This is very similar to a question I asked the other day but my
This is very similar to a question I asked the other day but my
My problem is very similar to this question , however I am posting a
I'd asked a very similar question earlier , but the project scope is quickly
This question is very similar to Loading a file into a vector ; however,
This question is very similar to one I recently asked: Python threading- returning control
I asked a very similar question earlier today, so you might get a bit
I know that this question is very similar to the question posted here .

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.