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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:56:09+00:00 2026-05-11T00:56:09+00:00

I am tired of always trying to guess, if I should escape special characters

  • 0

I am tired of always trying to guess, if I should escape special characters like ‘()[]{}|‘ etc. when using many implementations of regexps.

It is different with, for example, Python, sed, grep, awk, Perl, rename, Apache, find and so on. Is there any rule set which tells when I should, and when I should not, escape special characters? Does it depend on the regexp type, like PCRE, POSIX or extended regexps?

  • 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. 2026-05-11T00:56:10+00:00Added an answer on May 11, 2026 at 12:56 am

    Which characters you must and which you mustn’t escape indeed depends on the regex flavor you’re working with.

    For PCRE, and most other so-called Perl-compatible flavors, escape these outside character classes:

    .^$*+?()[{\| 

    and these inside character classes:

    ^-]\ 

    For POSIX extended regexes (ERE), escape these outside character classes (same as PCRE):

    .^$*+?()[{\| 

    Escaping any other characters is an error with POSIX ERE.

    Inside character classes, the backslash is a literal character in POSIX regular expressions. You cannot use it to escape anything. You have to use ‘clever placement’ if you want to include character class metacharacters as literals. Put the ^ anywhere except at the start, the ] at the start, and the – at the start or the end of the character class to match these literally, e.g.:

    []^-] 

    In POSIX basic regular expressions (BRE), these are metacharacters that you need to escape to suppress their meaning:

    .^$*[\ 

    Escaping parentheses and curly brackets in BREs gives them the special meaning their unescaped versions have in EREs. Some implementations (e.g. GNU) also give special meaning to other characters when escaped, such as \? and +. Escaping a character other than .^$*(){} is normally an error with BREs.

    Inside character classes, BREs follow the same rule as EREs.

    If all this makes your head spin, grab a copy of RegexBuddy. On the Create tab, click Insert Token, and then Literal. RegexBuddy will add escapes as needed.

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Set WINVER to the version of windows you want to… May 11, 2026 at 11:34 am
  • added an answer Twisted has an IRC client (in twisted.words), and it supports… May 11, 2026 at 11:34 am
  • added an answer One way to do it is to pass properties as… May 11, 2026 at 11:34 am

Related Questions

I am tired of always trying to guess, if I should escape special characters
I am starting a a new web development project and I am tired of
Possible Duplicate: JavaScript data formatting/pretty printer I am getting a bit tired of looking
I am involved in development of a tiered application that uses LINQ2SQL separated from
I am trying to add a timed delay in a C++ program, and was
I am working with an n-tiered architecture in Visual Studio 2008 (Developer Edition), and
I am using Visual Studio 2008 Express and I tried creating a simple console
I am using paging on a GridView that is tied to a List<Employee> .
I am very, very new to MYSQL.I tried to create a table named option.
I am very interested in streaming data for web-applications. I have tried out some

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.