[comp.lang.c] think before I post :-)

merlyn@iwarp.intel.com (Randal Schwartz) (07/12/89)

In article <6396@columbia.edu>, kearns@read (Steve Kearns) writes:
| A previous article claimed that 
| >| ----------------------------------------
| >| "/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/"
| >| ----------------------------------------
| 
| does not match 
| 
| >  /***/
| >(This one was easy. :-)
| 
| A guess it was not so easy.  "/***/" does indeed match the 
| above regular expression:
| 
| "/*""/"*([^*/]|[^*]"/"|"*"[^/])*"*"*"*/"
|        0                       0   1
| 
| Under each star I have listed how many times it iterates to match
| "/***/".  
| 
| -steve

OK, so I almost got it right.  What I meant to say was:

   /***//

is matched as the *BEGINNING* of a comment.  In other words,

   /***//  this text is merrily gobbled inside the comment */

is matched as an entire comment.  Remember, you can't just take an
arbitrary path through the regex... you need to think about "gobble
the most you can" rules too.

Sigh.  Wasn't the proper solution something with states and such?
And, when will this go on the "most frequent questions" list?

Putting my Lex-guru card on temporary suspension,
-- 
/== Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ====\
| on contract to Intel, Hillsboro, Oregon, USA                           |
| merlyn@iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn	         |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/