Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Modification of a read-only value attempted

by Anonymous Monk
on May 21, 2020 at 14:01 UTC ( #11117037=note: print w/replies, xml ) Need Help??


in reply to Modification of a read-only value attempted

Also, when writing regexes to parse strings like this, watch out for "greedy." Ordinarily a regex will "greedily" try to match the longest possible string, and this is often the wrong thing to do here.
  • Comment on Re: Modification of a read-only value attempted

Replies are listed 'Best First'.
Re^2: Modification of a read-only value attempted
by ikegami (Pope) on May 21, 2020 at 14:50 UTC
    Ordinarily a regex will "greedily" try to match the longest possible string

    No.

    # Matches 2 chars at pos 0, not 6 chars at pos 2. "acabbbbc" =~ /ab*c/

    Greediness applies to individual regex atoms, causing those to match as much as possible at the current position.

Re^2: Modification of a read-only value attempted
by AnomalousMonk (Bishop) on May 21, 2020 at 15:11 UTC

    Further to ikegami's reply:   The rule is to find the leftmost longest match. This has tripped me up more that once!


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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (6)
As of 2020-09-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (114 votes). Check out past polls.

    Notices?