Results 1 to 4 of 4

Thread: have doubt

  1. #1
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

    Question have doubt

    hi..
    can anyone tell me the output of following code about regular expression construction in java:

    A questionmark (?) indicates that the preceding character should appear zero or one times in the pattern.

    The pattern foo? can be found in "food" and "fod", but not "faod".

    My doubt is that the foo? means fo followed by 0 or 1". I am not able to understand and next thing....why foo? means "fo" followed by 0 or 1 not "foo" followed by 0 or 1??Also explain this?? can anyone explain this through a example?????

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Read that explanation again. It's not "fo" followed by 0 or 1. It's "fo" followed by 0 or 1 "o"s.
    It's the preceding character which should appear once or not at all.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,936
    Rep Power
    19

    Default

    "preceding character".
    The preceding character in "foo?" is the second "o", so you are saying "match where fo is followed by zero or 1 o's".

    ETA: Gah! Slow old fart...:)

  4. #4
    ras_pari is offline Member
    Join Date
    Oct 2009
    Posts
    40
    Rep Power
    0

Similar Threads

  1. doubt
    By Chris555 in forum Networking
    Replies: 0
    Last Post: 08-05-2009, 02:58 PM
  2. Doubt
    By winkodes in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 12-20-2008, 08:34 PM
  3. doubt
    By shaju_inspira in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 01-18-2008, 08:38 AM
  4. doubt in jms
    By veena in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 01-05-2008, 01:42 PM
  5. Doubt with classpath
    By fred in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 01:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •