in reply to Proper use of //x

1.) Do you find /x regexes easier to read/understand, or harder?

Easier to understand, harder to read, and harder to mod. I have found that if a regexp is complex enuff to warrant in line commenting then the inline commenting makes reading the expression itself too damn difficult. The danger IMHO is that you write a regexp then comment it with /x and in effect ensure that the code cannot be changed without removing the comments. I must confess I tend to not use /x I tend to place a comment block above the regexp and paraphrase complex regexp in that.

2.) Does this "ease of reading" change one way or the other as you gain experience with regexes?

I think that regexp cant be read at all like regular code (or at least I cant). When reading code I have long since stopped seeing the specific commands and instead look at the flow and interpolate. Just as when reading english I dont think I see all the words my brain just rushes over them filling in the details later. With regexps there seems to be no easy way to do this. I just sit down and read them statement by statement backfilling as required. It gets quicker, because I dont need to refer to a manual now *grins*.

3.) What kinds of rules should be followed when using /x to ensure the best readability?

Personally I dont use them at all often, the only time I would has already been listed in the thread, that being to break up regexp's that > 80 chars. I get quite cross if any code line is > 80 chars.

--

Zigster