Which I want to convert to:
?$line=2003/01/06 10:00:00 8651.88;
$line =~ s/ \[.*?\] //;
___
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
hi alejandro --
In a message dated 8/7/2006 10:26:03 A.M. Eastern Standard Time,
[EMAIL PROTECTED] writes:
I have this _expression_: $line="2003/01/06 10:00:00 [2003/01/06
15:00:00 UTC] 8651.88"; Which I want to convert to:
$line="2003/01/06 10:00:00 8651.88"; That is, match
$line=2003/01/06 10:00:00 [2003/01/06 15:00:00 UTC] 8651.88;
print $line\n;
$line =~ s/(\s+\[.*?\]\s+)/ /;
print $line\n;
What you were missing was . (period). \s+ is for one or more spaces
Rgds,
Nilesh
Alejandro Santillan wrote:
I have this expression:
$line=2003/01/06 10:00:00 [2003/01/06
$line=~s/\[*\]//g; but it doesn't work.
try this (note the dot before the *):
$line=~s/ \[ .* \] //xg;
dot star is always a concern, as it'll take everything including your
close square brackets, if there's more than one. If you want to be sure
that doesn't happen, the more general
Evan Morris wrote:
Hi
Why doesn't this code put the string some more text into the variable
$astring?
CODE:
$aline=some text|some more text|;
$astring = ($aline=~/\|*\|/);
Something like this should work better:
my $aline = 'some text|some more text|';
$aline =~ /\|(.*)\|/;
my $astring =
Of Jenda
Krynicky
Sent: 25 June 2002 18:56
To: [EMAIL PROTECTED]
Subject: Re: regex help?
From: michael higgins [EMAIL PROTECTED]
The problem hanging me up right now is the fixed field length in the
.dbf is too short -- so I decided to shorten most strings with the
following regexes.( I also
From: Joel Hughes [EMAIL PROTECTED]
Hi Jenda,
I like your elegant solution.
Could you talk thru your regex a bit more please? I like the mapping
thing but dont see how the regex knows how to apply it? Is it
something to do with the qr/?
joel
OK I'll go over the code again
I'd do it
I took your code and made up an address ('dnt know' was for $secln
since uncertain what that was):
street: 2441 Le Bain Drive Circle Boulevard dnt know
Output:
street: 2441 Le Bain Dr. Cir. Blvd. dnt know
I am on w2k running under as build 623 ( 5.6.0 )
Wags ;)
-Original
Jenda Krynicky writes:
I'd do it like this :
# set up the mapping
%replace = (
Boulevard = 'Blvd',
Street = 'St',
Drive = 'Dr',
Avenue = 'Ave',
Circle = 'Cir',
);
# prepare the regular expression
$regexp = join '|', keys %replace;
$regexp =
While the code is obviously not perfect,
I do not see why would it not work.
It will probably help to see some of
the original strings that go into these
substitutions.
( Do they have end-of-lines embedded in them ? )
Eugene Haimov
-Original Message-
From: michael higgins [mailto:[EMAIL
From: [EMAIL PROTECTED]
Jenda Krynicky writes:
I'd do it like this :
# set up the mapping
%replace = (
Boulevard = 'Blvd',
Street = 'St',
Drive = 'Dr',
Avenue = 'Ave',
Circle = 'Cir',
);
# prepare the regular expression
$regexp = join '|',
Thanks all!
Here may be the problem. The match/substitution that fails is at the end of
the string... I may need to see if there is no 'end-of-line' marker.
So, the data from this snippet: print REPORT :$street:\n;
:61 Susan Drive :
: :
: :
:2156 Overlook Drive :
: :
:750 Park Avenue #3-C :
12 matches
Mail list logo