Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Pattern matching forwards/backwards???

by Crian (Chaplain)
on Jun 15, 2009 at 11:00 UTC ( #771613=note: print w/replies, xml ) Need Help??

in reply to Pattern matching forwards/backwards???


2. /([^-.]{3})/


$_ = 'KLEWREGREG-----REGREGEWD....-EWGREGERABCSHRE..----...XFGHWW'; /([^-.]{3})[-.]*\QXFGHWW\E/; print $1;

Replies are listed 'Best First'.
Re^2: Pattern matching forwards/backwards???
by JavaFan (Canon) on Jun 15, 2009 at 11:03 UTC
    That assumes there are no dashes and dots between the three letters searched for. It would fail on:
    $_ = 'A-BCXFGHWW';
      A small change and it will work again:
      $_ = 'A-BCXFGHWW'; print join '', m/([^-.])[-.]*([^-.])[-.]*([^-.])[-.]*\QXFGHWW\E/;


      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://771613]
[Perl300]: Hi all
[Perl300]: I need suggestion for a module that'll help me to send email from my perl code. I want it secure and as simple as possible.
[Perl300]: I found from Super Search
[Perl300]: I found from Super Search, Net::SMTPS or Net::SMTP, MIME::Lite, Email as options

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (11)
As of 2017-10-17 15:47 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (233 votes). Check out past polls.