You haven't provided much detail...and no code that you have tried. You are much more likely to get more informative help if you post your code and let others see what you have tried. Search the perlmonks site. Its a great resource. (for example QandASection: regular expressions ) regardless... I'm assuming you have your data in some text file.

here's the data in a text file...

This is first sentence. This is second sentence.

You can try this for a start...

use strict; open (INP,"data.txt") || die "Cannot open data.txt\n"; while (my $line = <INP>) { if ($line=~/^This\b/i) { # first word This if ($line !~ /\bfirst\b/i) { # without word first if ($line =~ /\.$/) { # . at the end print $line; } } } }
I have written the comments next to the pattern match so you can see what's happening at each line. If you want to know what the symbols mean, its better to look at a table of regular expression symbols in perl. There is no other short cut. however, this is only one of ways you could do this. I'm sure people can come up with shorter, fancier and even easier ways to do this kind of pattern match. This why you need to post your code, and provide better problem descriptions... so people can suggest different things, and then you learn much more.

perliff

----------------------

-with perl on my side

"If you look at the code too long, the code also looks back at you"


In reply to Re: Reguar expression by perliff
in thread Reguar expression by selva

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.