Simple Regular Expression.
From: EFP (epridgett_at_woh.rr.com)
Date: 11/26/03
- Previous message: Eric J. Roode: "Re: Regexp issue . . ."
- Next in thread: Gunnar Hjalmarsson: "Re: Simple Regular Expression."
- Reply: Gunnar Hjalmarsson: "Re: Simple Regular Expression."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Nov 2003 08:24:01 -0800
Can anyone help me with a simple regular expression problem.
All that I want to do is take a list of known data and extract a
particular section of the string to form a new list.
Here is my code snipet:
my $fh = new FileHandle('c:\Units.txt') ; ## sucks up my work file
my @lines1 = <$fh>; ## assigns the filehandler contents to @lines1
foreach $string (@lines1) ## extract each line from @lines and put it
in $string
{
$string =~ m/\*@@\$/;
print "NewString :: $string\n";
}
Sample Units.txt data:
.\Source\CPP\ConnPool\src\oraUtils.pc@@
.\Source\CPP\ConnPool\src\sample.pc@@
.\Source\CPP\Services\src\OExceptServer.pc@@
.\Source\CPP\Services\src\Rees1440Server.pc@@
.\Source\CPP\Services\src\SWDTestServer.pc@@
.\Source\CPP\TestCases\TestRees1800\testRees1800Cursor.pc@@
.\Source\CPP\TSRI\Remis1\cxxsrc\Buffer_Area.pc@@
I just want the:
oraUtils.pc
I'd even settle for:
oraUtils.pc@@
So basically I want the contents between "\" and the "@@"
I thought that:
$string =~ m/\*@@\$/;
Would go to the end of the search line and find "@@" and get anything
"*" between the "@@" and the "\" and set $string to this new value.
What it returns is:
element:: .\Source\CPP\ConnPool\src\oraUtils.pc@@
Can anyone correct my understanding of regular expression and
assignment to a varibale.
Thanks.
EFP
- Previous message: Eric J. Roode: "Re: Regexp issue . . ."
- Next in thread: Gunnar Hjalmarsson: "Re: Simple Regular Expression."
- Reply: Gunnar Hjalmarsson: "Re: Simple Regular Expression."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|