On Mon, May 27, 2013 at 1:05 PM, Roland Mainz <[email protected]> wrote: > Question mainly for Glenn: > Is it possible to do regex matching&&extraction via read(1) which then > fills variables (or an array) with the matches ? The issue is that > while the (attached as "json2cpv.sh") JSON parser demo works it has > limitations because it requires to do all operations in-memory because > it relies on ksh93's pattern matching&&extration feature > ${s//pattern/replacement}+".sh.match". > > AFAIK I need something like this: > -- snip -- > while read -P "<pattern>" match1 match2 match3 ; do > <... parse_data ...> > done <"input_file.json" > -- snip -- > ... where read(1) option -P defines the pattern to be used and matches > are stored in the variables match1...match3 (or if -A is set in an > indexed+sparse array (like .sh.match works)) > > The question is whether this is possible... AFAIK the issue are... > - ... pattern matching needs to read ahead... at some point there's no > gurantee that the seek pointer can't be put back at the original > position if the match fails and the input is a pipe, right (even > "lookahead" via I_PEEK has AFAIK size limitations and is not > (currently) not available on Linux for pipes/fifofs) ? What should we > do then ? > - ... performance: each read(1) cycle has to re-parse the pattern... > the pattern cache will avoid most of the overhead, right ?
Uhm... ping ?! ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) [email protected] \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;) _______________________________________________ ast-developers mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-developers
