Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Greedy quantifiers  RSS feed

 
asha ganapathy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I wrote the above code and executed this
input : java regex1 "\d*" "ab34ef"
output: 01234456

input : java regex1 "\d?" "ab34ef"
output: 012334456

I did not understand why the output gives the index 6 when there are elements only from 0-5?
 
Bert Bates
author
Sheriff
Posts: 8945
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Asha -

I'm going to move this to the intermediate forum. If you're studying for the SCJP, then let us know and we'll move it to that forum instead

Bert
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!