Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regex Question from SCJP (Sierra & Bates)

 
Khalid Chowdhury
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Given:-



And the command line:


I'm confused as to why the output is 01234456

I'd be really grateful is someone could explain this.
 
Konrad Till
Greenhorn
Posts: 7
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is "234" in the output, because "34" match has been found at index 2.
Rest are indexes of zero-length matches, because * means zero or more.
See also exam watch on page 500 in the K&B book.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic