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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:46:50+00:00 2026-06-15T20:46:50+00:00

Does anybody know where in Pattern API the behaviour of this line of code

  • 0

Does anybody know where in Pattern API the behaviour of this line of code is described

System.out.println("000".matches("(0)\\10“));

I think few people can say what it prints until they run it. API says

\n Whatever the n-th capturing group matched

It does not say that n must be 1 digit. Is it 10-th or 1-th group in my test?

  • 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-15T20:46:52+00:00Added an answer on June 15, 2026 at 8:46 pm

    You attempt to match the character 0 between parenthesis, and then you want the previous matched character \1 to be there also, followed by a 0 character. 000 does verify that pattern and thus the match() method returns true, so it prints true.

    Since the matcher did not found 10 capturing groups, it interprets it as the first one \1 then the character 0.

    A more complex example shows that if the matcher find N capturing group > 9 and that the available number of capturing groups is enough, it works also:

    System.out.println(
        "01234567891011 01120".matches(
            "(0)(1)(2)(3)(4)(5)(6)(7)(8)(9)(10)(11) \\1\\12\\30"
        )
    );
    

    Is true because 0 is in the first capturing group \1 and 11 is in the capturing group \12, finally there is no captured group number \30 so it is interpreted as back reference \3 (which is character 2) then the character 0.

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

Sidebar

Related Questions

Does anybody know how to fill patterns in MonoMac, this code does nothing unfortunately.
Does anybody know why this function, when passed an invalid date (e.g. timestamp) to
Does anybody know how to programmatically disable the keyboard individual letter pop-up? (This blue
does anybody know how to insert code into lyx? just like what is available
Does anybody know how I can enable line numbers for Ruby (and Ruby on
Does anybody know why JQuery.browser.version returns 1.9.1.2 for Firefox 3.5.2 What's the pattern? How
Does anybody have know any sample/tutorial (a sample server using SocketAsyncEventArgs etc) code about
Does anybody know of a Javascript chart API that will handle scaling and labeling
Does anybody know what this error message means, when I go to Report->Check Dependencies:
Does anybody know when $(#submit).on(click, function(){ came out. Meaning what version of Jquery started

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.