laziness, impatience, and hubris | |
PerlMonks |
Re^5: Question about regex.by hippo (Bishop) |
on Sep 30, 2020 at 09:03 UTC ( [id://11122360]=note: print w/replies, xml ) | Need Help?? |
Your post exactly matches my own approach. Interestingly regexen are something of an exception for me. Unless they are fairly complicated I don't use /x. I've been thinking about this because it is, as you say, the exception. My conclusion is that often enough a regex will contain a short section of prose from somewhere else and it is trivial to paste this in from the other source. With /x one would then have to go through it manually and escape all the spaces or replace them with something else. The problem of course compounds with interpolation:
Good luck managing that with /x - far better without. When the regex starts to become too large/unwieldy I just split it into several shorter ones which are then combined which I find helps the logical flow too. For completeness: the one operator I do sometimes cuddle with operands is the range operator but that's likely a relic from some shells (such as bash) where whitespace around the same construct can cause problems. 🦛
In Section
Seekers of Perl Wisdom
|
|