Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Cool thread :) ... but can somebody help me out please? I think my understanding/knowledge of regex's is sorely lacking because I'm not able to follow the descriptions in the answers above! To explain my problem...

First of all, the original answers I came up with on paper before looking at anyone else's replies were...
"", 01, 11, 0001, 1001, 00101, 10101, 000001, 100001, 001101
... which I'm assuming are the incorrect 10 from looking at the posts above and the amount of experience the posters share compared to me! :)

I wrote a little program which spits out the first answers in agreement with abell's answer above, but not in agreement with dws's.

I think my stumbling block is understanding how the regex /(0|1(01*0)*1)*/ matches the 00? Could somebody explain this to me? I've read a lot of the references but in my mind I'm looking at it like this...

<Incorrect, Please Explain Why?>
1) I take the 0|1 and figure that (except for the empty string) it will match any string that begins 0 or 1.
2) I take the (01*0)* and figure that it will match nothing, 00 or 0x0 where x is an arbitrary number of 1's.
3) I assume the last 1 means there has to be a 1 at the end of the regex?! I know this is wrong from the answers I'm getting back but I don't know why! argh!
</Incorrect, Please Explain Why?>

Scratching his head and hoping for help,

UPDATE: I think zakb has hit the nail on the head for me with his answer :) ... Wow! Do I feel silly now ;)
I *think* if you add the brackets that I was interpreting around the 0|1 combination it makes the answers I came up with correct :) Of course it doesn't help you spot the pattern that no longer exists ;)

In reply to Re: Regex refresher by Nemp
in thread Regex refresher by FoxtrotUniform

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2023-01-29 01:51 GMT
Find Nodes?
    Voting Booth?

    No recent polls found