Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Debugging regular expressions

by clemburg (Curate)
on Jun 21, 2001 at 12:35 UTC ( #90309=note: print w/replies, xml ) Need Help??


in reply to Debugging regular expressions

I think the first debug trick is always avoid debug, i.e. write correct code :). And to write correct RE a good trick is comprehend what are you writing.

It also helps to "translate" the specification of how the to be parsed data looks like into a language that easily maps to regular expressions.

A good technique to avoid errors and to code a regex according to specification is to build up the regex from strings stored in variables, which you then interpolate into the regex. This also makes the regex much more readable for others. Re: Trying to avoid line noise (brain cramp) gives an example.

Christian Lemburg
Brainbench MVP for Perl
http://www.brainbench.com

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2022-09-26 04:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer my indexes to start at:




    Results (116 votes). Check out past polls.

    Notices?