Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Regexes vs. Maintainability

by hil (Sexton)
on Sep 29, 2000 at 05:42 UTC ( #34552=note: print w/replies, xml ) Need Help??

in reply to Regexes vs. Maintainability

This is purely anecdotal, of course, but regexes are just plain fun - to write, anyway. Supporting other people's can be a major source of annoyance. How many of them are really understandable to the average coder?

Personally, I prefer a general comment and then comments on specific parts only if the expression is particularly intricate (as in the example above). In any case, I would be interested to see how many people really bother to comment their regexes beyond "parses $var" or some such thing. I'm sure there are plenty of horror stories floating around.

Replies are listed 'Best First'.
RE: Re: Regexes vs. Maintainability
by mirod (Canon) on Sep 29, 2000 at 11:46 UTC

    I tend to comment regexps like this:

    $path=~/^\s*([\w-]+) # elt \s*\[\s*\@ # [@ ([\w-]+) # att $1 \s*=\s*(["']) # = " (or ',) $2 (.*?) # value $3 \3\]\s*$/gx) # "] (or ')

    It works very well for moderately complex regexps.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2023-04-01 10:30 GMT
Find Nodes?
    Voting Booth?

    No recent polls found