[ale] here's one for the script wizards

Asher Vilensky ashervilensky at gmail.com
Wed Feb 10 13:22:31 EST 2010


Thanks, everybody, for your help.  Geoffrey gets the ice cream.  ;-)

Here's something interesting I didn't mention up front (intentionally):  the
input file is in  Hebrew (right-to-left).  The text appears in the correct
orientation in a browser.  However, when I copied it into a  Linux file (or
just the terminal), it "changed" orientation:  it was still Hebrew, but
left-to-right.  I processed the input and pasted the results back to a web
form and wallah!!  it was right-to-left again.  (in reality I don't think it
ever changed orientation.  it's only that I didn't configure the xterm to
"speak" Hebrew.  It treated it all as binary bits.)

-- Asher


On Wed, Feb 10, 2010 at 12:14 PM, Richard Bronosky <Richard at bronosky.com>wrote:

> echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just
> flies' | sed 's/([^)]*) *//g'
>
> On Wed, Feb 10, 2010 at 12:05 PM,  <fletch at phydeaux.org> wrote:
> >
> >>
> >>> Sorry, I wasn't specific enough.  I'm looking to separate all the
> >>> parenthesized words from the non-parenthesized:
> >>>
> >>> input: foo (bar) ice cream (brown) sky is blue (airplane flies) just
> >>> flies
> >>>
> >>> output:
> >>> foo ice cream sky is blue just flies
> >>> (bar) (brown) (airplane flies)     --- with or without parenthesis, it
> >>> doesn't matter.
> >>
> >> Presuming the parens aren't nested
> >>
> >> $ echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just
> >> flies' | perl -lne
> >> 'my(@n, at p);my at d=m{(\(?[^()]+\)?)\s+}g;push@{$_%2==0?\@n:\@p},$d[$_]for
> >> 0..$#d;print join(" ", at n);print join(" ", at p);'
> >> foo ice cream sky is blue just
> >> (bar) (brown) (airplane flies)
> >
> > Bah, messed up the regex and it drops the last word.  Slightly tweaked
> > version works better.
> >
> > echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just
> flies'
> > | perl -lne
> > 'my(@n, at p);my at d=m{(\(?[^()]+\)?)(?:\s+|$)}g;push@
> {$_%2?\@p:\@n},$d[$_]for
> > 0..$#d;print join(" ", at n);print join(" ", at p);'
> > foo ice cream sky is blue just flies
> > (bar) (brown) (airplane flies)
> >
> > --
> > Fletch                | "If you find my answers frightening,       __`'/|
> > fletch at phydeaux.org|  Vincent, you should cease askin'          \
> o.O'
> >                      |  scary questions." -- Jules                =(___)=
> >                      |                                               U
> >
> >
> > _______________________________________________
> > Ale mailing list
> > Ale at ale.org
> > http://mail.ale.org/mailman/listinfo/ale
> > See JOBS, ANNOUNCE and SCHOOLS lists at
> > http://mail.ale.org/mailman/listinfo
> >
>
>
>
> --
> .!# RichardBronosky #!.
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20100210/6ea226c8/attachment.html 


More information about the Ale mailing list