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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:07:55+00:00 2026-05-29T09:07:55+00:00

a quick hand would be much appreciated. I’m trying to make a small algorithm

  • 0

a quick hand would be much appreciated.
I’m trying to make a small algorithm to input the text from a text box into a regex expression. As follows:

    string bar = String.Format(@"^{0}*(q*x|x*q)*", foo.Text);

the regex class is passed the bar variable above and initialized when the event is fired. However, it only returns hits when there is repeating text. E.G bb in the textbox returns all results that begin with b, and 1b returns matches on every word.

??? is there something wrong with my regex or my logic? (or both! :P)

EDIT i am attempting to match a list of strings loaded from a text file. all words that contain both a q and an x at least once, beginning with the letters in the text box. examples:
arquifoux
benzofuroquinoxaline
benzoquinoxaline
disquixote
equiaxe

  • 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-29T09:07:56+00:00Added an answer on May 29, 2026 at 9:07 am

    I think you want

    string bar = String.Format(@"^{0}.*?(q.*?x|x.*?q).*", foo.Text);
    

    The . matches any character.
    The question mark in .*? just makes the match non-greedy (ie the ‘q’ will match the first q it finds), although in your case they’re not really necessary.

    Your previous, ‘q*’, matches “0 or more q characters”.

    You could further improve your regex:

    string bar = String.Format(@"^{0}[a-z]*?(q[a-z]*?x|x[a-z]*?q)[a-z]*", foo.Text);
    

    Which only matches lowercase letters. (you could feed in the case insensitive flag to your regex to have it match any case).

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

Sidebar

Related Questions

I'm blacking out on my basic SQL and would appreciate a quick hand: I
I need a quick hand figuring out what this code is doing, and how
Quick question: Would it be a good or a bad idea to implement my
I am doing some text processing, part of it is splitting words into single
I'm trying add a bold/strong tag the line headings of the follow string/text block:
I know the parametric equations to 'hand draw' a circle. I would like to
Quick question...my wife is drafting a small agreement for her the IT company she
I would like to hear some opinions on hand coding your GUIs as one
Quick question. What do you think, I have a few sites that use a
Quick add on requirement in our project. A field in our DB to hold

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.