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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:00:50+00:00 2026-06-11T23:00:50+00:00

Suppose I check whether a string match a regex with wildcard. How can I

  • 0

Suppose I check whether a string match a regex with wildcard. How can I programatically get extract which substring replaces the wildcard?

Simple example: the regex is "[foo|bar].*\.txt" and say, a matching string that is found is “foo123.txt”. In this case the answer I want is “123”, since it is the substring that replaces the wildcard. If a matching string is bar0123456789.txt, then the answer is 0123456789.

I use c#, but I wouldn’t mind answers in other languages that I can also implement in c#

  • 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-11T23:00:52+00:00Added an answer on June 11, 2026 at 11:00 pm

    Don’t use square brackets, if you want a group. Square brackets create a character class.

    What you want is a non capturing group for that:

    (?:foo|bar).*\.txt
    

    To get the result from the .* (. is a special character that matches any character, but Newline characters (by default) and * is a quantifier that repeats the previous character 0 or more times), you need to put it into a capturing group.

    (?:foo|bar)(.*)\.txt
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose you have an NxN matrix and you have to check whether it's a
How do I check for time for between. suppose I have Time in string
In Python 3, how can I check whether an object is a container (rather
I have some text in a string, I need to check whether that particular
OK, suppose I want to check whether the template parameter has a nested type/typedef
Suppose a check constraint (involving multiple columns) with the not for replication option was
Suppose that I check-in a change in the wrong TFS branch. I need to
Suppose we need to check three boolean conditions to perform a select query. Let
Suppose I have created one jQuery function to check if elements exist or not
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input

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.