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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:33:18+00:00 2026-05-24T08:33:18+00:00

Within an ERE, a backslash character (\, \a, \b, \f, \n, \r, \t, \v)

  • 0

Within an ERE, a backslash character (\, \a, \b, \f, \n,
\r, \t, \v) is considered to begin an escape sequence.

Then I see \\n and [\\\n], I can guess though both \\n and [\\\n] here means \ followed by new line, but I’m confused by the exact process to interpret such sequence as how many \s are required at all?

UPDATE

I don’t have problem understanding regex in programing languages so please make the context within the lexer.

[root@ ]# echo "test\
> hi"
  • 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-24T08:33:19+00:00Added an answer on May 24, 2026 at 8:33 am

    This is dependent on the programming language and on its string handling options.

    For example, in Java strings, if you need a literal backslash in a string, you need to double it. So the regex \n must be written as "\\n". If you plan to match a backslash using a regex, then you need to escape it twice – once for Java’s string handler, and once for the regex engine. So, to match \, the regex is \\, and the corresponding Java string is "\\\\".

    Many programming languages have special “verbatim” or “raw” strings where you don’t need to escape backslashes. So the regex \n can be written as a normal Python string as "\\n" or as a Python raw string as r"\n". The Python string "\n" is the actual newline character.

    This can becoming confusing, because sometimes not escaping the backslash happens to work. For example the Python string "\d\n" happens to work as a regex that’s intended to match a digit, followed by a newline. This is because \d isn’t a recognized character escape sequence in Python strings, so it’s kept as a literal \d and fed that way to the regex engine. The \n is translated to an actual newline, but that happens to match the newline in the string that the regex is tested against.

    However, if you forget to escape a backslash where the resulting sequence is a valid character escape sequence, bad things happen. For example, the regex \bfoo\b matches an entire word foo (but it doesn’t match the foo in foobar). If you write the regex string as "\bfoo\b", the \bs are translated into backspace characters by the string processor, so the regex engine is told to match <backspace>foo<backspace> which obviously will fail.

    Solution: Always use verbatim strings where you have them (e. g. Python’s r"...", .NET’s @"...") or use regex literals where you have them (e. g. JavaScript’s and Ruby’s /.../). Or use RegexBuddy to automatically translate the regex for you into your language’s special format.

    To get back to your examples:

    • \\n as a regex means “Match a backslash, followed by n“
    • [\\\n] as a regex means “Match either a backslash or a newline character”.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Within the /etc/hosts file you can block traffic via ## # Host Database #
Within MVC 3, I am trying to figure out how to apply both role
Within my sql procedure I create an temporary table and then pivot it. This
Within Twitter Bootstrap there is a selection of buttons that one can choose from
Within the browser I can use this to open a pop-up window: System.Windows.Browser.HtmlPage.Window.Navigate(new Uri(uri),
Within my C++/QtTestLib Class, how can I get a count of the number of
Within a loop in my bash script, I am 'doing work', then writing the
Within an ASPX page, I would like to have the popup shown within the
Within an application, I've got Secret Keys uses to calculate a hash for an
Within Ruby on Rails applications database.yml is a plain text file that stores database

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.