On Thursday, Mar 20, 2003, at 14:23 US/Pacific, David Gilden wrote:
[..]
I am trying to get the following as a result:
xxx9988
#!/usr/bin/perl -w
$card_number = '123456789988';
$card_number =~ s/\d{8}(\d{4})/x'x'8 . $1/e; # not working
print "$card_number\n";
I presume when you run that
Remember to always group reply so others can help and be helped.
David Gilden wrote:
Why am I getting 'one two three' in $s and not just 'one'
You might want to print $1, this will give you a better idea. $1 is
being set to everything in the parentheses, which is everything you
match, and the
David Gilden wrote:
In the following why am I getting '23'
Is 23 being treated as a string?
Not exactly. It is NOT being treated as a number if that is what you
mean, all of $s is being treated as a string. Specifically \w matches
any "word" character, which is any alphanumeric...so [A-Za-z0-9_].
In the following why am I getting '23'
Is 23 being treated as a string?
#!/usr/bin/perl -w
use strict;
my $s = ' 23 one two three';
$s =~ s/(\w{1,10}).+/$1/;
print $s;
---
my $s = 'one two three';
$s =~ s/(\w)/$1/;
print $s;
Returns 'one two three', I was looking for it to match 'on
good afternoon,
I am trying to get the following as a result:
xxx9988
#!/usr/bin/perl -w
$card_number = '123456789988';
$card_number =~ s/\d{8}(\d{4})/x'x'8 . $1/e; # not working
print "$card_number\n";
Is there a clever trick using tr =~ or something similar?
Thanks!
Dave
--
To
: 16 February 2002 14:07
> To: David Gilden
> Cc: [EMAIL PROTECTED]
> Subject: Re: regrex question
>
>
> David Gilden wrote:
>
> >
> > $key ="Departure date";
> >
> > $key =~ s/([\w\w+])/\u$1/;
> >
> >
> > ---> De
David Gilden wrote:
>
> $key ="Departure date";
>
> $key =~ s/([\w\w+])/\u$1/;
>
>
> ---> Desired result:
>
> Departure Date
>
> What is wrong the above regrex?
it's probably easier to use the ucfirst() function:
my $key ="Departure date";
my @result = map { ucfirst } split /\s+/, $key;
$key ="Departure date";
$key =~ s/([\w\w+])/\u$1/;
---> Desired result:
Departure Date
What is wrong the above regrex?
Thanks!
Dave
**
* Cora Connection Your West African Music Source *
* http://www.coraconnection.com/