• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pattern matching doubt

 
Sen George
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The following code


compiles and runs fine.

Program produces an output of 'match' found in positions 0, 1, 2, 3, 4, 5, 6, 7, and 8. But no data groups. How is this explained-matches found but no data groups?

 
Henry Wong
author
Marshal
Pie
Posts: 21010
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Program produces an output of 'match' found in positions 0, 1, 2, 3, 4, 5, 6, 7, and 8. But no data groups. How is this explained-matches found but no data groups?


Well, look at the pattern....




This reluctantly matches zero or more digits. Since, zero digits is a valid match, an zero length string is a valid match -- which is what you are matching.

Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic