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

The Archive Base Latest Questions

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

I am writing a program in C# that compares strings similarly to the way

  • 0

I am writing a program in C# that compares strings similarly to the way that Google searches documents for keywords.

I am wanting a search for “stack overflow” to return true for “stack overflow” (plain), “This is the stack overflow.” (in the middle), “Welcome to Stack Overflow.” (case insensitive), “I like stack overflow.” (variable whitespace), and “Who puts a dash in stack-overflow?”, but not “stackoverflow” (no whitespace).

I was thinking that I could use a regular expression like “stack([ -]|. )+overflow”, it seems overkill to have to replace every space in each keyword with a character set for each new keyword. Because “stack overflow” is not the only string I am searching, I have to do it pragmatically.

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

    To meet your specification, you could first do

    newSearchString = Regex.Replace(Regex.Escape(searchString), @"\s+", @"[\s\p{P}]+");
    

    (to transform your plain text search string into a regular expression that also allows punctuation in places where there used to be only whitespace), and then apply that regex to whatever text you’re searching.

    But of course this will fail to match on the slightest typo whereas an algorithm using Levensthein distance will also match “Stak Overfloor”.

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

Sidebar

Related Questions

I am writing a program that runs some unit tests on code that that
I'm writing a program that displays products and the stores at which they can
I am writing a C# application that needs to read about 130,000 (String, Int32)
I'm stuck writing my program Here's what I wanted it to do: display a
It is my first time to create a program with file reading and writing
I have a number of Python generators, which I want to combine into a
This question is about the extent to which it makes sense unit testing. I’ve
Often a web service needs to zip up several large files for download by
I'm developing in python, still new to the game, and I want to make

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.