Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Clean number

Quote Reply
Clean number
If I have number like 07693086 that begin with 0 or 007693086 that begin with 00, who can I get the number without the 0 in the binging even if there 000; the zero in the middle or the end must stay.
So I will send this number 007603086 and get 7603086
Quote Reply
Re: [nir] Clean number In reply to
Should be pretty simple :)

remove_leading_zeros
Code:
sub {
my $num = $_[0];
$num =~ s/^0+//g;
return $num;
}

Then call with:

<%remove_leading_zeros($number_field)%>

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Clean number In reply to
ThanksSmile
In globule what is the code to see if the number 14600159 is in 00014600159
I try this but it not work
$cond->add('num' => Like => $temp);
Quote Reply
Re: [nir] Clean number In reply to
$cond->add('num' => Like => "%$temp"); ...should work

However, that would also match:

222214600159

...etc

I'm not sure how you would make % actually only match if the number if "0".

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Clean number In reply to
Thanks:)
Quote Reply
Re: [Andy] Clean number In reply to
Is there a way that this global will clean the first and the end zero. like 00930084700 will be 9300847?
Quote Reply
Re: [nir] Clean number In reply to
Simple:

Code:
sub {
my $num = $_[0];
$num =~ s/^0+//g;
$num =~ s/0+$//g;
return $num;
}

Angelic

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates