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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:04:23+00:00 2026-06-09T18:04:23+00:00

I was looking at some of the jdk code. I found these characters. Could

  • 0

I was looking at some of the jdk code. I found these characters. Could someone explain to me what do these mean.

public static String quote(String s) {
    int slashEIndex = s.indexOf("\\E");        // What does this mean. Is this a special char in java. if so what does this do.
    if (slashEIndex == -1)
        return "\\Q" + s + "\\E";          

    StringBuilder sb = new StringBuilder(s.length() * 2);
    sb.append("\\Q");
    slashEIndex = 0;
    int current = 0;
    while ((slashEIndex = s.indexOf("\\E", current)) != -1) {
        sb.append(s.substring(current, slashEIndex));
        current = slashEIndex + 2;
        sb.append("\\E\\\\E\\Q");
    }
    sb.append(s.substring(current, s.length()));
    sb.append("\\E");
    return sb.toString();
}

From the above code example I was able to figure out what’s happening as in the method finds the occurrences of \ and converts them to \E and \Q. Could someone explain why that’s the case.

For more context on this method, I was looking into the Pattern.quote() method from jdk 1.6

  • 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-09T18:04:24+00:00Added an answer on June 9, 2026 at 6:04 pm

    \Q and \E is exactly what Pattern.quote() does, that is to Returns a literal pattern String for the specified String.

    For more details see this link:

    http://docs.oracle.com/javase/1.5.0/docs/api/java/util/regex/Pattern.html

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

Sidebar

Related Questions

Looking at some source code, I found this operator () => { } From
I'm just beginning with C++, so I'm looking some code to learn. I found
Looking at some assembly code for x86_64 on my Mac, I see the following
Looking at some of the code System.Linq I've come across some examples of Buffer<TSource>
Looking for some help! I need to split a string at the last occurrence
while looking at some code I stumbled onto: throw /*-->*/new std::exception (//... and I
I would like to put JDK tools.jar as compile dependency. I found some examples
i was looking some code of some GWT classes, and, shamefully, i was unable
how convert string into Unicode string in Perl. I am looking some attribute in
Looking at some sample javascript code at http://alexgorbatchev.com/SyntaxHighlighter/manual/api/autoloader.html I see: <script src=shCore.js type=text/javascript></script> <script

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.