Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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???

1. /\QXFGHWW\E/

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

together:

$_ = '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/;

      CountZero

      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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://771613]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2015-08-01 03:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (285 votes), past polls