Dharshana Eswaran wrote:
On 3/9/07, John W. Krahn <[EMAIL PROTECTED]> wrote:

Chas Owens wrote:

[snip]
               (
                       \w+ |
                       \d+ |
                       0x[a-fA-F0-9]

That only matches a single hexadecimal digit, you probably want
0x[a-fA-F0-9]+
instead.


>                )                     # capture a word, int, or hex
>                \s*                   # optional spaces
>                (?:
> ( # capture the various int operators
>                                [+-|^*/%] |

                                 [+-|^&*/%] |


>                                <<        |
>                                >>
>                        )

What about:

TOKEN & ~TOKEN

Or:

TOKEN * -TOKEN

:-)

[snip]

Thank you for the suggestions. I tried both ways.

 0x[a-fA-F0-9]

That only matches a single hexadecimal digit, you probably want
0x[a-fA-F0-9]+
instead.

When i tried Chas's idea, without this correction itself i could get the hex
values more than a digit.

But i did not understand the below lines mentioned by John.
What about:

TOKEN & ~TOKEN

Or:

TOKEN * -TOKEN

:-)

Can you please explain it?

Thanks once again for the immediate response.

Hi Dharshana

The reason your version works is that Chas has coded

(\w+|\d+|0x[a-fA-F0-9])

and something like 0x0011 will be matched fine with \w+. In fact anything that
matches either \d+ or 0x[a-fA-F0-9]+ will also match \w+ so there is no point
in putting them in.

What John means is that perhaps the expression could be a bit mask - the base
value ANDed with the bitwise negation of the modifier. This is common in
setting up optiohn bitmaps or similar. Or the base could be multiplied by
minus the modifier - which as far as I can tell is completely useless (he does
put a smiley in here!). In my solution I assumed that the modifier would
always be added or ORed into the base and so the operator was irrelevant. You
also said that you didn't need the operators extracting from the definitions.

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to