Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: RegEx + vs. {1,}

by Athanasius (Monsignor)
on Oct 10, 2012 at 16:03 UTC ( #998250=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %seen;
    
    ...
    {
        ++$seen{$1}, pos($string) -= length($1) - 1 while $string =~ /(\w{
    +$len})/g;
    }
    
  2. or download this
    ----------------------------------------------------------------------
      (?{$seen{$1}++})         run this block of Perl code
    ----------------------------------------------------------------------
      (?!)                     fail
    ----------------------------------------------------------------------
    
  3. or download this
    (*FAIL) (*F) 
    
    This pattern matches nothing and always fails. It can be used to force
    + the engine to backtrack. It is equivalent to (?!), but easier to rea
    +d. In fact, (?!) gets optimised into (*FAIL) internally.
    
  4. or download this
    $string =~ /(\w{2,})(?{$seen{$1}++})(?!)/;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2014-12-29 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (185 votes), past polls