Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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;

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2016-12-05 03:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (72 votes). Check out past polls.