, 2002 2:16 PM
> To: [EMAIL PROTECTED]
> Subject: Re: simple string parsing
>
>
> Ellie Quigley's Perl by Example is fantastic.
>
> >>> Robert Boardman <[EMAIL PROTECTED]> 12/27/02 11:50AM >>>
> Thank you to everyone I now have a much better un
Ellie Quigley's Perl by Example is fantastic.
>>> Robert Boardman <[EMAIL PROTECTED]> 12/27/02 11:50AM >>>
Thank you to everyone I now have a much better understanding of
parsing
lines,
Robb
PS could you recommend any good starter perl books?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For a
Thank you to everyone I now have a much better understanding of parsing
lines,
Robb
PS could you recommend any good starter perl books?
On Fri, 2002-12-27 at 16:50, R. Joseph Newton wrote:
> my $InString = " channel="carlton.com">"
> if ($InString =~ /\bprogramme start=\"(.*)\" stop=\"(.*)\" cha
my $InString = ""
if ($InString =~ /\bprogramme start=\"(.*)\" stop=\"(.*)\" channel=\"(.*)\"/) {
my $programme = $1;
my $start = $2;
my $channel = $3;
}
What happens here is that the parentheses around each sought-after value set it to one
of the built-in regex variables--$1, $2...$n, i
> $string = "\ stop=\"20021222001000
> UTC\" channel=\"carlton.com\>";
> ($programme, $stop, $channel) = ($string =~
> m/\S+\s\S+\"(\d+)\s\S+\s\S+\"(\d+)\s\S+\s\S+\"(\S+)\"\>/);
>
> If the <> were not actually part of the string, this will
> work the same
> ($programme, $stop, $channel) = ($st
$string = "\";
($programme, $stop, $channel) = ($string =~
m/\S+\s\S+\"(\d+)\s\S+\s\S+\"(\d+)\s\S+\s\S+\"(\S+)\"\>/);
If the <> were not actually part of the string, this will work the same
($programme, $stop, $channel) = ($string =~
m/\S+\s\S+\"(\d+)\s\S+\s\S+\"(\d+)\s\S+\s\S+\"(\S+)\"/);
Maybe