• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
I am displeased. You are no longer allowed to read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic