Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Re: Can perl find strings over multiple lines?

Thread Tools

Re: Can perl find strings over multiple lines?

Posts: n/a
Paul Lalli wrote:
> Removed) wrote:
>> Is it possible to search for strings in a file over multiple lines
>> using a one-liner from the shell?

> Yes, it is.
>> What I want to do is find all the text between
>> a line beginning with "--" or "-- " and
>> ending with ")$" where '$' is, of course, the EOL char.
>> I also would like to know how to find the exclusion
>> so that the output produces everything but the enclosed string above.
>> Is this possible with perl?

> Yes, it is.
> If you would like assistance with the demonstration of such abilities,
> please read and follow the Posting Guidelines for the group. Most
> specifically, please post your best attempt to solve the problem
> you're having, along with a description of how your attempt is not
> working sufficiently. Be sure to include example input, desired
> output, and actual output.

While it's always good for one to attempt to solve their own problem, I
don't see why the assumption is often made that they did not do so.
Further more, why are some people so concerned with that in the first
place? Especially for a potentially simple answer in this case.

He gave a description of what he was trying to do. You could of included
an answer similar like mine )below) instead of just general guidelines
and leave it at that. Do not get me wrong, your guidelines are good for
general purposes, but by themselves do not really offer anything to the
topic it self.

It sounds to me like he could find the 's' modifier for a regex match,
which cause the '.' meta char to match embedded new lines.

This should to do what the OP wants (un tested):

@matches = $full_text =~ m!--(.*?)\)\$!sg;

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
Can perl find strings over multiple lines? osiris@abydos.kmt Perl Misc 5 11-20-2006 11:07 PM
Strings, Strings and Damned Strings Ben C Programming 14 06-24-2006 05:09 AM
str.find for multiple strings Bart Nessux Python 7 02-12-2004 06:26 PM
passing multiple strings to string.find() hokiegal99 Python 3 08-09-2003 03:55 PM