Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Regex Homework

by Corion (Patriarch)
on Feb 24, 2004 at 07:15 UTC ( [id://331341]=note: print w/replies, xml ) Need Help??


in reply to Regex Homework

A good approach to abstract problems with regular expessions is to write down some concrete examples and then look at these to see a common pattern emerging. I will not do the complete work for you, because much of the process lies in thinking about what "good" concrete examples are, and in thinking about whether you did find all relevant examples or not.

For your case a), the following list could be interesting:

abc abababc ababcab abcabab abcabcab abcabcccccccccccccccab

Another thing that will be helpfull for you to meditate over is the relation between the terms "odd" and "even". A nonnegative whole number is called "odd", if the number before it is called "even". A number is called "even", if the number before it is called "odd", or if it is zero.

If you still have problems going forward with this, start with an easier example:

  • c1) Find a regular expression that matches exactly any string consisting of an even number of "d". The empty string is also considered to contain an even number of "d".
  • c2) Modify that regular expression so that it matches exactly any string consisting of an odd number of "d".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://331341]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2024-04-25 21:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found