Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: How to modify my regex?

by OldChamp (Acolyte)
on Aug 26, 2015 at 20:43 UTC ( #1140117=note: print w/replies, xml ) Need Help??


in reply to Re: How to modify my regex?
in thread How to modify my regex?

Hi, AnomalousMonk, many thanks for helping me again, now my program works. It's really astonishing what this "lazy" modifier can change! I have read about greedy and lazy, but because of the lack of an example, I have not really understood what this means. Now I think I have at least an idea of this modifier and tomorrow I will visit the links you have supplied and hopefully I will become a little more knowlegeable.

Replies are listed 'Best First'.
Re^3: How to modify my regex?
by AnomalousMonk (Bishop) on Aug 26, 2015 at 23:10 UTC

    You're very welcome. It may seem a bit churlish to bring this up after your gracious thanks, but it dawned on me that the subject of the OP was familiar, and I was right: Re^3: Substitution don't work discusses a similar problem. Updates 2 & 3 there give contrasting examples of  .* versus  .*? (greedy versus lazy) behavior. (Also see the discussion there of the effect of the  /s regex modifier on the behavior of the  . (dot) metacharacter when matching against a multi-line string.)

    These comments are not intended to give you a hard time, but to suggest that the advice of the humble Monks will be of more value to you the more attention you pay it.


    Give a man a fish:  <%-{-{-{-<

      Thank you for your answer. I must confess, that at the time when reading your reply to 'Substitution don't work' I didn't understand this Updat 3, especially the meaning of the " ", and I had no clue what these [[ should mean. As I am just at the beginning with perl, I thought these characters are some special codes I just don't know yet, because there are so many characters with special meanings in perl. Now (that means today), after all the friendly posts of the humble Monks and after studying these posts and trying to understand what I read I finally have understood that between the " " that is the code and that the other stuff is meant to explain how the regex works. I eventually succeded in running this update 3 and I could see how it works. I agree, I should have tried harder the first time when I read this update 3. But for my defence I have to say that for experienced Monks like you all this is obvious, but for a newbie like me (72 years old :-) and as a German always fighting with my school English) even the obvious is sometimes not easy. I have learned a lot from you and the other monks since I have started here and I'm greatful to this community.

        Believe me, every experienced Monk started as a novice! And don't worry about your English: I find it quite clear — and it's a lot better than my German!


        Give a man a fish:  <%-{-{-{-<

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2022-10-05 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred way to holiday/vacation is:











    Results (25 votes). Check out past polls.

    Notices?