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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:51:07+00:00 2026-05-16T14:51:07+00:00

I’m not even sure if this is possible or not, but here’s what I’d

  • 0

I’m not even sure if this is possible or not, but here’s what I’d like.

String: "NS306 FEBRUARY 20078/9/201013B1-9-1Low31 AUGUST 19870"

I have a text box where I type in the search parameters and they are space delimited. Because of this, I want to return a match is string1 is in the string and then string2 is in the string, OR string2 is in the string and then string1 is in the string. I don’t care what order the strings are in, but they ALL (will somethings me more than 2) have to be in the string.

So for instance, in the provided string I would want:

"FEB Low"

or

"Low FEB"

…to return as a match.

I’m REALLY new to regex, only read some tutorials on here but that was a while ago and I need to get this done today. Monday I start a new project which is much more important and can’t be distracted with this issue. Is there anyway to do this with regular expressions, or do I have to iterate through each part of the search filter and permutate the order? Any and all help is extremely appreciated. Thanks.

UPDATE:
The reason I don’t want to iterate through a loop and am looking for the best performance wise is because unfortunately, the dataTable I’m using calls this function on every key press, and I don’t want it to bog down.

UPDATE:
Thank you everyone for your help, it was much appreciated.

CODE UPDATE:

Ultimately, this is what I went with.

string sSearch = nvc["sSearch"].ToString().Replace(" ", ")(?=.*");
if (sSearch != null && sSearch != "")
{
  Regex r = new Regex("^(?=.*" + sSearch + ").*$", RegexOptions.IgnoreCase);
  _AdminList = _AdminList.Where<IPB>(
                                       delegate(IPB ipb)
                                       {
                                          //Concatenated all elements of IPB into a string
                                          bool returnValue = r.IsMatch(strTest); //strTest is the concatenated string
                                          return returnValue;
                                    }).ToList<IPB>();
                                       }
}

The IPB class has X number of elements and in no one table throughout the site I’m working on are the columns in the same order. Therefore, I needed to any order search and I didn’t want to have to write a lot of code to do it. There were other good ideas in here, but I know my boss really likes Regex (preaches them) and therefore I thought it’d be best if I went with that for now. If for whatever reason the site’s performance slips (intranet site) then I’ll try another way. Thanks everyone.

  • 1 1 Answer
  • 2 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-16T14:51:07+00:00Added an answer on May 16, 2026 at 2:51 pm

    You can use (?=…) positive lookahead; it asserts that a given pattern can be matched. You’d anchor at the beginning of the string, and one by one, in any order, look for a match of each of your patterns.

    It’ll look something like this:

    ^(?=.*one)(?=.*two)(?=.*three).*$
    

    This will match a string that contains "one", "two", "three", in any order (as seen on rubular.com).

    Depending on the context, you may want to anchor on \A and \Z, and use single-line mode so the dot matches everything.

    This is not the most efficient solution to the problem. The best solution would be to parse out the words in your input and putting it into an efficient set representation, etc.

    Related questions

    • How does the regular expression (?<=#)[^#]+(?=#) work?

    More practical example: password validation

    Let’s say that we want our password to:

    • Contain between 8 and 15 characters
    • Must contain an uppercase letter
    • Must contain a lowercase letter
    • Must contain a digit
    • Must contain one of special symbols

    Then we can write a regex like this:

    ^(?=.{8,15}$)(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*[!@#$%^&*]).*$
     \__________/\_________/\_________/\_________/\______________/
        length      upper      lower      digit        symbol
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I want to count how many characters a certain string has in PHP, but
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
Does anyone know how can I replace this 2 symbol below from the string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
I would like to count the length of a string with PHP. The string

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.