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

Re: Pattern matching forwards/backwards???

by Crian (Curate)
on Jun 15, 2009 at 11:00 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://771613]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2024-03-29 05:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found