Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Return just number

Quote Reply
Return just number
Is there a way to send to a global data and get back just number? Something like
<%format_telephone("aaa sss 000-000-0001234")%>
and It will return
000-000-0001234
Quote Reply
Re: [nir] Return just number In reply to
This should do it:

Code:
$test =~ s/[\D\-]+//;

..so:

Code:
sub {
my $val = $_[0];
$val =~ s/[\D\-]+//;
return $val;
}

Hope that helps.

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] Return just number In reply to
Thanks Andy,
It return just the number, but it return it like
000000-0001234
instead of
000-000-0001234
Quote Reply
Re: [nir] Return just number In reply to
Are you sure you actually have "-" , and not a charachter looks similar?

I just tested it myself and it works fine:

Code:
use strict;

my $test = test(qq|aaa sss 000-000-0001234|);

print "TEST: $test \n";

sub test {
my $val = $_[0];
$val =~ s/[\D\-]+//;
return $val;
}

Quote:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

C:\Users\Andy>perl test.pl
TEST: 000-000-0001234

C:\Users\Andy>

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] Return just number In reply to
It look that if we have sign before the number it work fine, but if I have sign after the number or I have just number it not work correct.
Quote Reply
Re: [nir] Return just number In reply to
Got an example? You're description isn't "very descriptive" Whistle

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] Return just number In reply to
Smile
If I insert this to the globals
"aaa sss 000-000-0001234" it return "000-000-0001234" - that good:)

If I insert this to the globals
"000-000-0001234 aaa sss" it return "000000-0001234 aaa sss"

If I insert this to the globals
"000-000-0001234" it return "000000-0001234"

The bast is if it always return 000-000-0001234
Quote Reply
Re: [nir] Return just number In reply to
Not quite as pretty, but this version works:

Code:
sub {
my @back;
foreach (split //, $_[0]) {
if ($_ =~ /[\d-]/) { push @back, $_ }
}
return join("", @back);
}

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] Return just number In reply to
ThanksSmile, it's work.