[ragel-users] Re: Newbie question - regarding anchoring

gautham a n angaut... at yahoo.com
Fri Jun 29 05:12:12 UTC 2007


Hi,

Thanks for the reply.

I am afraid I was not specific enough in my query. I understand that if I am looking for a substring, say "Hello" in the input string, It will match even if "Hello" is not at the beginning of the string. So, the following machine
    main := "Hello" @ {printf("you said hello.\n");};
would print "you said hello.\n" for both input strings - "Hello world" and "world Hello abcdef".

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



More information about the ragel-users mailing list