[thelist] regexp help

Henry, Frank frank.henry at hp.com
Mon Jul 14 11:34:53 CDT 2003


The space after "04" is getting included in the substring. Try this:

if($string=~/04 (.*?)\|/gi){
    $substring=$1;
}

Or, you could trim any remaining spaces from the start of the substring
like so:

$substring =~ s/^\s+//;

hope this helps.

- frank.
______________________________________
Frank Henry (frank.henry at hp.com)


-----Original Message-----
From: Richard Bennett [mailto:richard.bennett at skynet.be] 
Sent: 14 July 2003 17:14
To: thelist at lists.evolt.org
Subject: [thelist] regexp help

Hi,
I have a long string that I'm parsing in Perl, like this:

 11 aaa| 2355 bbbb| 04 aff gge|...

When I search for 04 I want to get the value 'aff gge' in a variable

So far I'm trying like this, but it's not returning the correct string:

if($string=~/04(.*?)\|/gi){
    $substring=$1;
}

Any ideas?

Richard.
-- 
* * Please support the community that supports you.  * *
http://evolt.org/help_support_evolt/

Evolt.org conference in London, July 25-27 2003.  Register today at
http://evolt.org.uk

For unsubscribe and other options, including the Tip Harvester 
and archives of thelist go to: http://lists.evolt.org 
Workers of the Web, evolt ! 


More information about the thelist mailing list