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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:46:13+00:00 2026-06-13T06:46:13+00:00

In a .NET Regex pattern, what special characters need to be escaped in order

  • 0

In a .NET Regex pattern, what special characters need to be escaped in order to be used literally?

  • 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-13T06:46:14+00:00Added an answer on June 13, 2026 at 6:46 am

    I don’t know the complete set of characters – but I wouldn’t rely on the knowledge anyway, and I wouldn’t put it into code. Instead, I would use Regex.Escape whenever I wanted some literal text that I wasn’t sure about:

    // Don't actually do this to check containment... it's just a little example.
    public bool RegexContains(string haystack, string needle)
    {
        Regex regex = new Regex("^.*" + Regex.Escape(needle) + ".*$");
        return regex.IsMatch(haystack);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following regex pattern: (.NET 1.1 Regex Validator) ^(?=.*[A-Za-z])[a-zA-Z0-9@\\-_\\+\\.]{6,32}$ I need to
What is the JavaScript equivalent of this .NET code? var b = Regex.IsMatch(txt, pattern);
I need a regex pattern (must be a single pattern) to match any text
How to escape all regex characters automatically using built-in .NET mechanism or something like
I'm trying to use a .NET Regex to validate the input format of a
This is a continuation of my previous question .NET regex engine returns no matches
I find the class Regex in .net extremely useful (for both matching and matching/replacing).
I'm performing regex matching in .NET against strings that look like this: 1;#Lists/General Discussion/Waffles
i know there are several questions about regex recursion in .net. I can write
I'm developing a VB.NET 1.1 web application. All validation and RegEx controls work perfectly

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.