On Tue, 13 May 2008, (HL, who wrote me off-list) wrote:

 > Dan Singer wrote:
 > > On Tue, 13 May 2008, Glenn Fowler wrote:
 > >
 > >  > this will do it
 > >  >         print "${buf/?(*$'\n')@(part5:*([^\n]))*/\2}"
 > >
 >
 > Extended shell patterns use a kind of prefix notation
 >
 >      prefix lparen shell-patterns [ bar shell-pattern ] rparen
 > ...

Ah, thanks (to you and David)!  I had managed to space that out.  It
all just looked very cryptic.

I ran into a similar problem a few months ago, and handled it somewhat
more awk-wardly (w/ prefix patterns, btw):

 npat="[0-9][0-9]:[0-9][0-9]:[0-9][0-9]"

 # extract the time string out of a line
 function extract_time {
        typeset tstr="$1"
        typeset bstr estr
        eval "bstr=\${tstr/%@($npat)*/}"
        eval "estr=\${tstr/#*@($npat)/}"
        tstr=${tstr#$bstr}
        tstr=${tstr%$estr}
        print -- "$tstr"
 }

Good to know that there's a good one-liner to do the job.  Let's see,
would that be

  eval "print -- \"\${tstr/?(*)@(${npat})*/\2}\""

?? (seems to work)

-- 
Daniel E. Singer, System Administrator
Dept. of Computer Science, Duke University, Durham NC 27708 USA
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to