Thanks, everybody, for your help. Geoffrey gets the ice cream. ;-)<br><br>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.)<br>
<br clear="all">-- Asher <br>
<br><br><div class="gmail_quote">On Wed, Feb 10, 2010 at 12:14 PM, Richard Bronosky <span dir="ltr"><<a href="mailto:Richard@bronosky.com">Richard@bronosky.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just<br>
</div>flies' | sed 's/([^)]*) *//g'<br>
<div class="im"><br>
On Wed, Feb 10, 2010 at 12:05 PM, <<a href="mailto:fletch@phydeaux.org">fletch@phydeaux.org</a>> wrote:<br>
><br>
>><br>
>>> Sorry, I wasn't specific enough. I'm looking to separate all the<br>
>>> parenthesized words from the non-parenthesized:<br>
>>><br>
>>> input: foo (bar) ice cream (brown) sky is blue (airplane flies) just<br>
>>> flies<br>
>>><br>
>>> output:<br>
>>> foo ice cream sky is blue just flies<br>
>>> (bar) (brown) (airplane flies) --- with or without parenthesis, it<br>
>>> doesn't matter.<br>
>><br>
>> Presuming the parens aren't nested<br>
>><br>
>> $ echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just<br>
>> flies' | perl -lne<br>
>> 'my(@n,@p);my@d=m{(\(?[^()]+\)?)\s+}g;push@{$_%2==0?\@n:\@p},$d[$_]for<br>
>> 0..$#d;print join(" ",@n);print join(" ",@p);'<br>
>> foo ice cream sky is blue just<br>
>> (bar) (brown) (airplane flies)<br>
><br>
</div>> Bah, messed up the regex and it drops the last word. Slightly tweaked<br>
> version works better.<br>
<div class="im">><br>
> echo 'foo (bar) ice cream (brown) sky is blue (airplane flies) just flies'<br>
> | perl -lne<br>
</div>> 'my(@n,@p);my@d=m{(\(?[^()]+\)?)(?:\s+|$)}g;push@{$_%2?\@p:\@n},$d[$_]for<br>
<div class="im">> 0..$#d;print join(" ",@n);print join(" ",@p);'<br>
</div><div class="im">> foo ice cream sky is blue just flies<br>
> (bar) (brown) (airplane flies)<br>
><br>
> --<br>
</div><div class="im">> Fletch | "If you find my answers frightening, __`'/|<br>
> fletch at <a href="http://phydeaux.org" target="_blank">phydeaux.org</a>| Vincent, you should cease askin' \ o.O'<br>
> | scary questions." -- Jules =(___)=<br>
> | U<br>
><br>
><br>
> _______________________________________________<br>
> Ale mailing list<br>
> <a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
> <a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
> See JOBS, ANNOUNCE and SCHOOLS lists at<br>
> <a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
><br>
<br>
<br>
<br>
</div><font color="#888888">--<br>
.!# RichardBronosky #!.<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</div></div></blockquote></div><br>