Hey Darren,

The one thing you overlooked in your answer is that .* is greedy, so
that regex will also match things like:

/*+ FIRST_ROWS DOMAIN_INDEX_SORT */ and lots of other stuff */

Might not be an issue, but anytime I write .* in a regex, I double
check to see if something else might be better used.  In the example
you give, it's likely that \S+ , or maybe even [^\S\*]+ is the right
thing.

Or maybe you just want to make the quantifier lazy by using '.*?'
(Or combine both...)

(BTW, fix that damn dmass nav bar too.... 8^)

<Steve>

On Tue, 19 Feb 2002, darren chamberlain wrote:

> Make it easy on yourself: use a delimiter other than /; I'm using
> ',' below, since it doesn't appear in your regex.  Also, use the
> /x modifier to make it commentable:
>
> # Your regex: \/\*\+\s+(.*)\s+\*\/
> if ($query =~ m,
>                   /\*\+   # Opening, looks like /*+
>                     \s+   # some whitespace
>                      (.*)
>                     \s+   # some whitespace
>                   \*/     # Closing, looks like */
>               ,x) {
>     $hint = $1;
> }
>
> Not using / avoid toothpick syndrome, and spacing it out makes it
> much easier to read.
>
> You might want to use .+ rather than .* in the middle; .* will
> match 0 or more characters, which means that the empty string
> also matches (although in boolean context it returns false, so
> the if() clause doesn't get executed).
>
> Judging from your description of the hint, I assume that you are
> later splitting $hint into FIRST_ROWS and DOMAIN_INDEX_SORT
> pieces; why not do it here:
>
> if ($query =~ m,
>                   /\*\+   # Opening, looks like /*+
>                     \s+   # some whitespace
>                      (.+) # FIRST_ROWS
>                     \s+   # some whitespace
>                      (.+) # DOMAIN_INDEX_SORT
>                     \s+   # some whitespace
>                   \*/     # Closing, looks like */
>               ,x) {
>     $hints{$1} = $2;      # Or whatever
> }
>
> (darren)
>
>

-- 
Steve Reppucci                                       [EMAIL PROTECTED] |
Logical Choice Software                          http://logsoft.com/ |
=-=-=-=-=-=-=-=-=-=-  My God!  What have I done?  -=-=-=-=-=-=-=-=-=-=


Reply via email to