note
Nemp
Hello!<br><br>
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...<br><br>
First of all, the original answers I came up with on paper before looking at anyone else's replies were...<br>
<code>"", 01, 11, 0001, 1001, 00101, 10101, 000001, 100001, 001101</code><br>
... 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! :)<br><br>
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.<br><br>
I think my stumbling block is understanding how the regex <code>/(0|1(01*0)*1)*/</code> 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...<br><br>
<b><Incorrect, Please Explain Why?></b><br>
1) I take the 0|1 and figure that (except for the empty string) it will match any string that begins 0 or 1.<br>
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.
<br>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!<br>
<b></Incorrect, Please Explain Why?></b><br><br>Scratching his head and hoping for help,<br>Neil<br><br>
<b>UPDATE:</b> I think zakb has hit the nail on the head for me with his answer :) ... Wow! Do I feel silly now ;)<br>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 ;)
197155
197155