Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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;

Comment on Re: Pattern matching forwards/backwards???
Select or Download Code
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]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-09-01 09:31 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (369 votes), past polls