For Programmers: Free Programming Magazines  


Home > Archive > AWK > April 2005 > Grammar rules for regexps.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Grammar rules for regexps.
E. Rosten

2005-04-15, 8:55 am

Hi, awkers,

I'm getting a bit about the rules for what is a regexp and what
isn't (inspired by the confusion that the vim syntax highlighter suffers
from).

I'm assuming it's something to do with precedence, but can anyone
enlighten me further?

Take this:

awk -va=1 -vb=1 -vc=1 '{print a /(b+1)/ c, /(b+1)/, a (/b+1/) c}'

The first expression had the thing between the /s evaulated numerically,
the second has it evaluated as a regexp (in gawk, at any rate). The third
(fairly obviously because of the brackest) has it as a regexp (the space
is necessary to prevent a(...) looking like a functions).

Why? What are the rules?

Thanks

-Ed

--
(You can't go wrong with psycho-rats.) (er258)(@)(eng.cam)(.ac.uk)

/d{def}def/f{/Times findfont s scalefont setfont}d/s{10}d/r{roll}d f 5/m
{moveto}d -1 r 230 350 m 0 1 179{1 index show 88 rotate 4 mul 0 rmoveto}
for /s 15 d f pop 240 420 m 0 1 3 { 4 2 1 r sub -1 r show } for showpage

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com