Interesting little regex

Jayce^ jason at infogenix.com
Thu Feb 23 11:18:59 MST 2006


Charles Curley wrote:
>> You've got the x flag, please use it!
> 
> You mean this regex is x rated?

hehe...
actually though, for any who don't know:
In perl regex, there are flags at the end (to be fixed, perl6 has them 
rightly in the front) that modify your engine.  One of these is the 
underutilized x modifier.  When added, it makes whitespace insignificant 
in your regex, so you can nicely tab/space/newline in order to actually 
be readable...  Oh, and you can/should add comments also. so:

s/(foo|bar)//;

can be
s/
     (		# either
         foo
       |		# or...
         bar
     )
  //x;


very simplified, but the basic point is there.  Make things readable, 
comment, etc....

--
Jayce^



More information about the PLUG mailing list