[RndTbl] Oh great RE master

Sean Walberg sean at ertw.com
Wed May 9 16:05:17 CDT 2007


 # echo BUILD-AM005-a | sed 's/[^0-9]//g'
005

Sean



On 5/9/07, Steve Moffat <Steve.Moffat at ca.ibm.com> wrote:
>
> Hi All;
> I've been trying to write a sed function to return only a numeric portion
> of a string, but can't seem to get it working.
> The input is a single string of letters and numbers, with the numbers
> always consecutive.
> For example: BUILD-AM005-a
>
> I want to get the 005 out of this string.
>
> echo BUILD-AM005-a | sed 's/.*\([[:digit:]]\).*/\1/g'
>
> will return the digit 5. This is good!
>
> So I add an asterisk to try to match multiple digits like:
> echo BUILD-AM005-a | sed 's/.*\([[:digit:]]*\).*/\1/g'
>
> and instead of returning 005, it doesn't match anything, so returns
> nothing.
>
> Can any of you RE maters help me out?
>
> Steve Moffat
> IBM Global Services
> sjm at ca.ibm.com
> (204)792-3245
>
> _______________________________________________
> Roundtable mailing list
> Roundtable at muug.mb.ca
> http://www.muug.mb.ca/mailman/listinfo/roundtable
>
>


-- 
Sean Walberg <sean at ertw.com>    http://ertw.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.muug.mb.ca/pipermail/roundtable/attachments/20070509/7030e08a/attachment.html


More information about the Roundtable mailing list