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.
|
|---|