Code Comments
Programming Forum and web based access to our favorite programming groups.I'd like to replace all non-numbers in a field with blanks. A sample of
the field is '100-Test', where the '100' should be the only thing left
in the field when the substitution has completed.
I've tried the following:
{sub(/[^0-9]*/,"",$24);print}
...but it does not seem to remove the non-numbers. I assume there is
something wrong with my logic here, but am not 'seeing' it.
Please assist.
Post Follow-up to this messageIn article <cngnaq0ro5@enews1.newsguy.com>,
python1 <python1@spamless.net> wrote:
> I'd like to replace all non-numbers in a field with blanks. A sample of
> the field is '100-Test', where the '100' should be the only thing left
> in the field when the substitution has completed.
>
> I've tried the following:
>
> {sub(/[^0-9]*/,"",$24);print}
>
> ...but it does not seem to remove the non-numbers. I assume there is
> something wrong with my logic here, but am not 'seeing' it.
>
> Please assist.
gsub vs sub
{gsub(/[^0-9]/,"",$24);print}
Bob Harris
Post Follow-up to this messageBob Harris wrote:
> gsub vs sub
>
> {gsub(/[^0-9]/,"",$24);print}
>
> Bob Harris
Works great. Thanks.
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.