Simple question to experts
Simple question to experts
am 05.11.2007 13:51:17 von lucavilla
Hi all!
The simple problem is this: I have a file named example.html on my
harddisk and I want to extract from that file a block of text that
goes from the regex "foobar[0-9]" to the first occurrence of the regex
"abcdef[0-9]".
What's the Perl/command-line/single-line solution for this?
Thanks in advance for any help
Re: Simple question to experts
am 05.11.2007 17:03:07 von Paul Lalli
On Nov 5, 7:51 am, Luca Villa wrote:
> Subject: Simple question to experts Options
Please put the subject of your post in the Subject of your post.
> The simple problem is this: I have a file named example.html on my
> harddisk and I want to extract from that file a block of text that
> goes from the regex "foobar[0-9]" to the first occurrence of the
> regex "abcdef[0-9]".
> What's the Perl/command-line/single-line solution for this?
It's my birthday, and I'm feeling generous. Here, have a fish:
perl -ln0777 -e'print $1 if /foobar[0-9](.*?)abcdef[0-9]/'
example.html
Then read:
perldoc perlrun
perldoc perlre
to understand what's happening.
Paul Lalli
Re: Simple question to experts
am 05.11.2007 17:30:33 von krahnj
Paul Lalli wrote:
>
> It's my birthday,
Ooh, a Scorpio! Happy birthday Paul. Many happy returns.
John
--
use Perl;
program
fulfillment
Re: Simple question to experts
am 05.11.2007 21:02:16 von unknown
Post removed (X-No-Archive: yes)
Re: Simple question to experts
am 06.11.2007 03:13:52 von Tad McClellan
Paul Lalli wrote:
> It's my birthday,
Those are good for you.
A federally funded study has shown that people with the most birthdays...
....
....
.... live the longest.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
Re: Simple question to experts
am 06.11.2007 12:56:15 von Joe Smith
Luca Villa wrote:
> Hi all!
>
> The simple problem is this: I have a file named example.html on my
> harddisk and I want to extract from that file a block of text that
> goes from the regex "foobar[0-9]" to the first occurrence of the regex
> "abcdef[0-9]".
> What's the Perl/command-line/single-line solution for this?
Look for "Range Operators" (scalar context) in `perldoc perlop`.
perl -n -e 'print if /foobar\d/ .. /abcdef\d/' example.html
-Joe
Re: Simple question to experts
am 06.11.2007 13:51:18 von Paul Lalli
On Nov 6, 6:56 am, Joe Smith wrote:
> Luca Villa wrote:
> > The simple problem is this: I have a file named example.html on
> > my harddisk and I want to extract from that file a block of text
> > that goes from the regex "foobar[0-9]" to the first occurrence
> > of the regex "abcdef[0-9]".
> > What's the Perl/command-line/single-line solution for this?
>
> Look for "Range Operators" (scalar context) in `perldoc perlop`.
>
> perl -n -e 'print if /foobar\d/ .. /abcdef\d/' example.html
That will include all text before /foobar\d/ on the first line, and
all text after /abcdef\d/ on the last line. The OP said he wanted the
text that is between the two patterns.
Paul Lalli
Re: Simple question to experts
am 06.11.2007 18:30:21 von Jim Gibson
In article , Tad McClellan
wrote:
> Paul Lalli wrote:
>
> > It's my birthday,
>
>
> Those are good for you.
>
> A federally funded study has shown that people with the most birthdays...
>
> ...
>
> ...
>
> ... live the longest.
But did they find a causal relationship, or was it more of a
statistical correlation?
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Re: Simple question to experts
am 07.11.2007 16:44:11 von Ted Zlatanov
On Tue, 06 Nov 2007 09:30:21 -0800 Jim Gibson wrote:
JG> In article , Tad McClellan
JG> wrote:
>> Paul Lalli wrote:
>>
>> > It's my birthday,
>>
>>
>> Those are good for you.
>>
>> A federally funded study has shown that people with the most birthdays...
>>
>> ...
>>
>> ...
>>
>> ... live the longest.
JG> But did they find a causal relationship, or was it more of a
JG> statistical correlation?
It's causal. Those pesky February 29 birthdays keep throwing the
statistics off :)
Ted