• 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

In Java regex, are the reluctant character somehow derived from greedy characters?

 
Greenhorn
Posts: 11
Eclipse IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was going through the SCJP book into the section of regex. It first states that of the following greedy quantifiers:
* - zero or more
+ - one or more
? - zero or one
On the topic of 'greedy' quantifiers, it then describes reluctant quantifiers:
?? - one or zero
*? - zero or more
+? - one or more
Are those signs somehow derived from greedy quantifiers? Or is it something like the !(inverse) and !=(not equals) signs, where both ! marks are totally unrelated? It seems to me, that the ? in the reluctant is unrelated, rather than buliding up some logic, like one or zero AND one or zero in the first line of the reluctant.
I know this is not present on the exam, but still, it helps to clarify.
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The question mark after the quantifier just indicates that the quantifier is reluctant. It is unrelated to the question mark that says zero or one.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic