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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:20:14+00:00 2026-05-15T11:20:14+00:00

I have a specialized string dictionary of (string, string) (_RulesAndTheirDescriptions) that contains the name

  • 0

I have a specialized string dictionary of (string, string) (_RulesAndTheirDescriptions) that contains the name (key) and description (value) of methods in a given class. I currently do the following query to search for a match on the key or value and then bind that to a grid. Works great!

Dim Results = From v In _RulesAndTheirDescriptions _
 Where v.Value.ToString().ToUpper().Contains(Me.txtSearchFor.Text.ToUpper()) _
 Or v.Key.ToString().ToUpper().Contains(Me.txtSearchFor.Text.ToUpper()) _
 Order By v.Key _
 Select New With {.Rule = v.Key, .Description = v.Value.ToString()}

This works great when matching “word” or perhaps even “my word” but I would like to search for “my” and “word” and “also this”. Meaning words and phrases seperated by spaces. Much like google and bing. When the user enters a value I only would require that the phrases be quoted. The following RegEx takes care of getting me a list word/phrase the user is looking for. Now I am having a hard time combining the the above query that works with the new enhanced list.

Please excuse the below code. I am just trying to test things and get it working.

Dim b As Match
b = Regex.Match(Me.txtSearchFor.Text, "(?<=(?:^|\s|,)"")[^""]*?(?="")|(?<=\s|^)(?!"")[\w\W]+?(?=\s|$)")

Dim sl As List(Of String) = New List(Of String)

If b.Success Then
    sl.Add(b.Value.ToUpper())

    Dim sMatch = b.NextMatch()

    While sMatch IsNot Nothing AndAlso sMatch.Success
        sl.Add(sMatch.Value.ToUpper())
        sMatch = sMatch.NextMatch()
    End While
End If

Per another post on this site I tried to do the following but that is not returing any results. I suspect because the sl.ToString() returns the type and not the value?

Dim Results = From v In _RulesAndTheirDescriptions _
 Where v.Value.ToString().ToUpper().Contains(sl.ToString()) _
 Order By v.Key _
 Select New With {.Rule = v.Key, .Description = v.Value.ToString()}

If I am going about this all wrong, please enlighten me. Seems like it should be easy.

Thanks in advance,
Kevin

  • 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-15T11:20:14+00:00Added an answer on May 15, 2026 at 11:20 am

    Hello You have to have a cross join to solve this problem

    Dim Results = From v In _RulesAndTheirDescriptions _
    join y in  sl on 1 equals 1 
     Where v.Value.ToString().ToUpper().Contains(y) _
     Order By v.Key _
     Select New With {.Rule = v.Key, .Description = v.Value.ToString()}
    

    This can produce duplicates when more than one token can match a rule.So you can do a distinct if you want unique values

    Like  Results.Distinct()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.