Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: shortening substitutions

by Thilosophy (Curate)
on Jun 17, 2005 at 11:25 UTC ( #467660=note: print w/ replies, xml ) Need Help??


in reply to shortening substitutions

Why do you want to do that? These four statements are very readable, combining them into one complex one would result in less readily understandable code.

In addition to that, I think an equivalent single regex would be tricky to think of. Just consider the delicate details:

  • You want to match each substituation only once. One quotation mark, one semicolon, leading white-space, one group of exactly four spaces.
  • The order in which you do these substitutions is relevant. Non-leading spaces can become leading spaces by stripping away a quotation mark, for example (which could also combine runs of spaces into four spaces).
Trying to preserve all that in a single statement makes my head hurt.

Some of these complexities are maybe in error. I do not know what you are trying to do, of course, but perhaps you want to strip all quotation marks, not only the first one. Once you need to debug code, four simple regex are easier to grasp than one complex regex.

So, I would suggest to stick with what you have now.


Comment on Re: shortening substitutions

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2014-10-25 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls