think before I post :-) (was Re: regex for C comments)
Randal Schwartz
merlyn at iwarp.intel.com
Thu Jul 13 02:20:41 AEST 1989
In article <6396 at columbia.edu>, kearns at 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 at iwarp.intel.com ...!uunet!iwarp.intel.com!merlyn |
\== Cute Quote: "Welcome to Oregon... Home of the California Raisins!" ==/
More information about the Comp.lang.c
mailing list