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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:41:38+00:00 2026-06-06T16:41:38+00:00

I have an input which gets a statement from the user. According with the

  • 0

I have an input which gets a statement from the user. According with the usage of my program, users can enter a character or a regular expression. After filling this input, users have to fill a second input that is the replacement text.

The problem is, user can type . and this is equivalent to a regular expression, which matches any character.

Does the below code work? Or, what’s the solution?

Match m = Regex.Match(input, pattern);
if( m.Success )
   // it's regex
else
  // it's not regex
  • 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-06T16:41:40+00:00Added an answer on June 6, 2026 at 4:41 pm

    You can’t*.

    Let’s look at how Visual Studio solves this problem:

    enter image description here

    As you can’t tell whether or not the user intended the content to be a regular expression, the designers allow the user to choose, giving the user complete control over how they want the search to be performed. If you want it to be plain text (the default), just hit Find Next. Otherwise, you can tailor your search using the additional options.

    *Well, you kind of can

    The other approach to this problem is to assume the user meant to search using every technique you support, and filter the results; grouped by “Plain Text” matches, and “Regular Expression” matches. This is less efficient but could be considered more user friendly as the user doesn’t actively have to choose any options. So you first search by just plain text, and return those matches under the heading “Plain Text Matches”, and then search assuming the string is a regular expression, and return those matches under the heading “Regular Expression Matches”

    Once you have displayed these to the user, they can choose which one they actually meant for the replace.

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

Sidebar

Related Questions

I have got a html web page which gets a user input in the
I have a simple java code which gets html text from the input url:
I have a function which gets a key from the user and generates a
I have a program which gets commands as a string. Each character in the
I have a some script, which gets the value from request: $body = file_get_contents('php://input');
I have an AJAX program which gets data from the website and posts the
I have an input string such as x=y|a=b|c=10 etc which gets converted to dynamic
I have a streaming input which has repeated values. I can use any data
I want to have a function which gets a text as the input and
I have a text input field which i have made readonly so the user

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.