logo       

Re: How to extract Numbers: msg#00067

editors.sed.user

Subject: Re: How to extract Numbers

Surya Kiran Gullapalli wrote:
> Hi all,
> I've a string like this
>
> AAAxx.yy
> where AAA are letters and xx and yy are numbers. I want to extract xx.yy
> from the string. I'm doing some thing like this.
>
> echo abc12.34 | sed -e 's|^\D*\(\d.*\)|\1|g'
>
> but the result i'm getting is abc12.34 only. Where am i doing wrong ?

I don't know what \D and \d are (I can guess). Here's how I would do it
with BSD's sed.

echo abc12.34 | sed -e 's/[^0-9.]*\([0-9]*\)/\1/g'

--
+--- Steve Ahrendt ---+
| Industrial Control Systems Service and Design |
+--- http://repairguy.net ---+


------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/2jUsvC/tzNLAA/TtwFAA/dkFolB/TM
--------------------------------------------------------------------~->

--

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sed-users/

<*> To unsubscribe from this group, send an email to:
sed-users-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/






<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise