Go Back   Velocity Reviews > Newsgroups > PERL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

PERL - Parse::Recdescent match word exactly with regular expressions

 
Thread Tools Search this Thread
Old 01-15-2009, 12:34 PM   #1
Default Parse::Recdescent match word exactly with regular expressions


Hi,

( using parse::recdescent 1.94 )
I want to parse a string and search for a word (and exactly this word). I
use the following grammar:

my $grammar = <<'_EOGRAMMAR_';

any : /[a-zA-Z0-9\d\., +-]+/

cmd_unknown : any(s)
{ main::cmd_unknown(); $return = 1;}

cmd_doit : /doit/
{ main::cmd_doit(); $return = 1; }

cmd : cmd_doit
| cmd_unknown

startrule: <skip: qr/[ \t]*/> cmd

_EOGRAMMAR_


The input "doit\r\n" works and executes the cmd_doit. But using the string
"doitnow\r\n" as input it also executes the cmd_doit function.

I want something like:

cmd_doit : /^doit$/ # saying the sentence must begin and end with doit. but
this syntax doesnt work?!

Any suggestions?

Thanx for your time.








ccm news
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Match or not ?? Renato Carvalho DVD Video 0 04-16-2007 04:05 PM
DVD Verdict reviews: MATCH POINT, DUMA, LATE SPRING: CRITERION COLLECTION, and more! DVD Verdict DVD Video 0 05-22-2006 09:24 AM
DVD Regional Codes need to match foreign DVDs Mordido DVD Video 1 10-18-2003 08:48 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46