Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: basic question: regular expression

by Ratazong (Monsignor)
on Dec 01, 2016 at 07:34 UTC ( #1177016=note: print w/replies, xml ) Need Help??


in reply to basic question: regular expression

Hi!

The reason is that * and ? also match zero times. So in your example 1, the regEx already matches the first k, which is followed by zero as. Even if a longer sequence comes later on in the string.

If there is a match, the regEx tries to be as greedy as possible, that's why you get kkka in example 2.

HTH, Rata

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2020-06-05 04:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?



    Results (35 votes). Check out past polls.

    Notices?