Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: substitution in regular expression

by trizen (Hermit)
on Apr 23, 2014 at 22:52 UTC ( #1083484=note: print w/ replies, xml ) Need Help??


in reply to Re^2: substitution in regular expression
in thread substitution in regular expression

Short explanation: (?{...}) means to execute arbitrary Perl code inside a regular expression, and (?!) makes the regex engine to fail and backtrack, trying to match from the last_pos + 1. When it starts matching ABC, it prints it, fails, backtracks and starts matching from B the next three letters, giving us BCD. The process repeats until the internal regex counter reaches the end of the string.

I know, I'm really bad at explaining things to humans, but, fortunately, Athanasius explained this better once.

Please see: Re: RegEx + vs. {1,}


Comment on Re^3: substitution in regular expression
Select or Download Code
Replies are listed 'Best First'.
Re^4: substitution in regular expression
by aeqr (Novice) on Apr 23, 2014 at 23:05 UTC
    Thanks a lot! Very well explained actually. It's a nice trick to know.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (17)
As of 2015-07-31 14:52 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 (278 votes), past polls