Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^5: Question about regex.

by haukex (Bishop)
on Sep 30, 2020 at 07:17 UTC ( #11122357=note: print w/replies, xml ) Need Help??

in reply to Re^4: Question about regex.
in thread Question about regex.

My rule of thumb is to use white space where possible as you would for prose on the basis that that is what we are most used to parsing so we get a fair bit of the parsing work essentially for free.

I also tend to use whitespace around operators and after commas, but at the same time, personally I can read things like $/=""; easily, which is why I don't always put whitespace around operators if the expression is short - if I'm coding for myself, I just base it on my feeling of readability. If I had to make a choice for a best practice recommendation though, I'd say whitespace around operators is good.

Interestingly regexen are something of an exception for me.

For me, regexes don't always read easily, especially if there's a lot of nested parens going on, so when trying to understand a regex, I'll often add the /x and whitespace.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2021-06-21 17:23 GMT
Find Nodes?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)

    Results (99 votes). Check out past polls.