• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Greedy Qualifiers | Pattern Matching

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,


When we try to the run the above mentioned code using :
java Regex "a?" "aba"
should produce something very similar to this:
Pattern is a?
0 1 a
1 1
2 3 a
3 3

How do we get this? What is the concept of zero-length matches and the I totally fail to understand the greedy and reluctant qualifiers
Please help.

Thanks in adv.
 
Ranch Hand
Posts: 44
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This POST explains the concept of greedy quantifiers very nicely.

PS: I found the answer to your question by searching the forum. Please try and do the same before posting. The quantity, quality and variety of questions/answers discussed in this forum is simply amazing for OCPJP. Searching and reading other posts in this forum here will probably help you not only find your answer but will also give you insights and understanding on other aspects or areas relevant to the exam that you were not familiar or unclear about. I say this with respect to my own experience of spending some time here.
Of course, if you still have doubts after searching then post away
 
reply
    Bookmark Topic Watch Topic
  • New Topic