[ragel-users] Re: Newbie question - regarding anchoring
Adrian Thurston
thurs... at cs.queensu.ca
Fri Jun 29 14:05:04 UTC 2007
Hello,
gautham a n wrote:
> would print "you said hello.\n" for both input strings - "Hello world"
> and "world Hello abcdef".
That is true of regular expressions as they are commonly known, but it
is not the case with Ragel. Ragel is more like a parser generator that
works with regular languages than a regular expression engine. If you
wanted to match the second string you would either have to put an "any*"
at the front or manually re-call the machine at every input location.
Cheers,
Adrian
>
> But, what would I need to do if I wanted the above printf() to be called only in the case when "Hello" is found at the beginning of the input string and, don't want the printf() to be called if some other substring is present at the beginning of the input string ?
>
> Thanks in advance.
>
> -gautham
>
> ----- Original Message ----
> From: Adrian Thurston <thurs... at cs.queensu.ca>
> To: ragel-users at googlegroups.com
> Sent: Thursday, June 28, 2007 8:55:43 PM
> Subject: [ragel-users] Re: Newbie question - regarding anchoring
>
> Hi,
>
> Ragel does not employ a regular expression matching engine, just a
> simple state machine which begins operation at the start of the input
> string. Since it does not attempt to match a pattern at every input
> position you don't need ^ to restrict the pattern to the beginning of an
> input string.
>
> Cheers,
> Adrian
>
> gautham wrote:
>> Hi,
>>
>> I am new to Ragel. I am trying out different regular expressions to
>> gain more familiariaty.
>>
>> I am unable to write a regex which is matched only when it is found at
>> the beginning of the input string. For example, the regex should match
>> "hello world start" and not match "world hello start".
>>
>> I tried using "^hello" - similar to lex/awk, but the "^" seems to be
>> interpreted literally.
>>
>> Thanks in advance.
>>
>> -gautham
>>
>>
>>
>
>
>
>
>
>
> ____________________________________________________________________________________
> Sick sense of humor? Visit Yahoo! TV's
> Comedy with an Edge to see what's on, when.
> http://tv.yahoo.com/collections/222
>
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "ragel-users" group.
> To post to this group, send email to ragel-users at googlegroups.com
> To unsubscribe from this group, send email to ragel-users-unsubscribe at googlegroups.com
> For more options, visit this group at http://groups.google.com/group/ragel-users?hl=en
> -~----------~----~----~----~------~----~------~--~---
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 252 bytes
Desc: OpenPGP digital signature
URL: <http://www.colm.net/pipermail/ragel-users/attachments/20070629/6eec8f27/attachment-0001.sig>
More information about the ragel-users
mailing list