Thanks David,
I'm afraid I'm still confused.
print ${string//!(g)}
This compares string to the pattern !(g) and subtracts off the
matching part. The pattern !(g) matches everything except g itself
Right, so if the matching part is everything except "g" itself, why
isn't everything except "g" subtracted?
My real string is this:
color="color red, resn ARG and resi 366"
I want the color to be returned and nothing else (it could also be
yellow or orange).
I hoped that ${color//!(red|yellow|orange)} would do it, but it always
returns empty.
${color//+(red|yellow|orange)} works like I expect, but does the exact
opposite of what I'm after, i.e. subtracts the color and returns the
rest of the string.
Currently my workaround is:
color=$(print $color | awk '{print $2}' | tr -d ",")
but I don't like calling awk if it can be done inside the shell.
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
_______________________________________________
uwin-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/uwin-users