On 2/12/2012 6:39 PM, lynn wrote:
On 02/13/2012 12:05 AM, lynn wrote:
I'm regex'd out of it at the moment. Given a string like this:
lynn:*:3000002some other stuff100hellolynn:
Is there a way to get the 3000002 into a variable v1 and the 100 into a variable v2? bash? Any recommended starting point? Thanks, L x
Thinking out loud: v1="lynn:*:3000002some other stuff100hellolynn:";echo "${v1//[!0-9]}" gives: 3000002100
But I may have: lynn2:*:3000002some other stuff100hellolynn: which gives: 23000002100
How to select only the 3000002 Thanks
it's not the most efficient, but I think something like: string="lynn:*:3000002some other stuff100hellolynn:" v1=`echo $string | sed -e "s/^.*:\*://" -e "s/[a-z ].*//"` v2=`echo $string | sed -e "s/^.*:\*:[a-z0-9]* [a-z ]*//" \ -e "s/[a-z]*://"` echo v1 $v1 echo v2 $v2 might be somewhat usable. assuming high performance isn't the rule of the day. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org