>>> "Peter" == Peter O'Gorman <[EMAIL PROTECTED]> writes:
> 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) How about using IFS? IFS=- host=powerpc-apple-darwin8.1.0 set X $host; shift a=$1; shift b=$1; shift c="$@"
