Peter O'Gorman wrote:
Paul Eggert wrote:

"Peter O'Gorman" <[EMAIL PROTECTED]> writes:


% expr "Xpowerpc-apple-darwin8.1.0" : 'X[^--]*-[^--]*-\(.*\)'



How about the following instead?  I'd rather use a simpler regexp if
it works.  Can you please verify that this works on the broken
implementation?  Thanks.

$ expr 'Xpowerpc-apple-darwin8.1.0' : '.*-\(.*\)'
darwin8.1.0
$ expr 'Xpowerpc-apple-darwin8.1.0' : '.*-\(.*\)-.*'
apple
$ expr 'Xpowerpc-apple-darwin8.1.0' : 'X\(.*\)-.*-'
powerpc


Yes, this works also. Thank you.

To reply to myself, Bill Fenner just mentioned on irc that this will give a bad result for "i686-pc-linux-gnu" he instead suggests using [.-.] as in:
expr "Xpowerpc-apple-darwin8.1.0" : 'X[^.-.]*-[^.-.]*-\(.*\)'
expr "Xpowerpc-apple-darwin8.1.0" : 'X[^.-.]*-\([^.-.]*\)-.*'
expr "Xpowerpc-apple-darwin8.1.0" : 'X\([^.-.]*\)-.*-.*'


irc paste, sorry
22:29 < fenestro> although if you want all 3 parts, using set and echo | sed is
                  probably less processes (if expr isn't builtin)
22:30 < fenestro> set `echo foo-bar-baz-boo | sed -e
                  's/\([^-]*\)-\([^-]*\)-\(.*\)/$1 $2 $3/'
22:30 < fenestro> a=$1
22:30 < fenestro> b=$2
22:30 < fenestro> c=$3

Or simply reverting and using echo | sed... (I prefer this solution)

Peter
--
Peter O'Gorman - http://www.pogma.com


Reply via email to