![]() |
| |||||||
![]() |
| | LinkBack | Thread Tools | Search this Thread | Display Modes |
| |||
| Rik wrote: > On Wed, 14 Feb 2007 02:12:32 +0100, Generale Cluster > <alex@carrarosoftmasters.net> wrote: > >> Jerry Stuckle ha scritto: >>> Generale Cluster wrote: >>>> Jerry Stuckle ha scritto: >>>>> Rik wrote: >>>>>> Generale Cluster <alex@carrarosoftmasters.net> wrote: >> [CUT] >>> That's the difference. I prefer code which is easily understandable. >>> You had trouble getting it to work in the first place. What happens >>> when you have to look at it six months or a year from now when you >>> have to work on it again? You'll go through all of his again to >>> understand what it does. >> [CUT] >> >> comment, comment, comment and comment again :-) > > Commenting in the single line? > Just tell them to leave everything between <?php ?> alone and it should > be OK, no reason to forced single line statements. About that, if you're > worried about that, then why not just code it on the single line on > normal code? Linebreaks aren't actually required in PHP, so you could > just leave them in, and when the code needs to be updated you can whip > it into some kind of formatted readable shape quite fast with any > competent texteditor. > > But the main reason for me posting here in this thread is about > commenting: I'd like to take the oppertunity advocate the user of the /x > modifier for regexes. These pesky little things are often forgotten in > the commenting, while it's so easy. > > Compare (not a very useful regex, just an illustration): > > $regex = '/(a|b){2,4}([^\s]+?)c{2,4}(.*?)q/si' > > And > $regex = '/{a|b}{2,4} #start matching at 2 to 4 a's or b's in a row > ([^\s]+?) #capture all non whitespace untill the next match > c{2,4} #match 2 to 4 c's > (.*?) #capture any character > q #until q > /six'; //case-insensite, with comments > > Now, that will be a lot easier altered and understood by coworkers I'd > imagine.. > --Rik Wasmus Rik, I agree - this makes a lot more sense, especially to those of us who are regex-challenged. :-) I really do wish more people would comment their regex's. It sometimes takes me a while to decode just what they're trying to do. -- ================== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstucklex@attglobal.net ================== |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |