Saturday, February 5, 2011

Kyōryū Sentai Zyuranger

x modifier in regular expressions, Perl

About Perl to read more often, that there is a "write-only" is language. As an example, usually followed by one expression.

Even yesterday it was time again :

definitely a write-only language: can not understand A THING of the code I wrote few weeks ago if ($ _ = ~ / ^ \\ d * \\ s ([^ \\ s] *) \\ s (.)/){
First has not the understanding of regular expressions really do too much with Perl. The's in (almost) any language. In Java, it would be even more cryptic:

if (String.match (". \\ \\ D * \\ \\ s ([^ \\ \\ s] *) \\ \\ s ()")) {}
Well, who noted the double "\\ \\"? But that's not the point. Second, you can use the x modifier in Perl. This space lose their meaning in regular expressions and "#" can make comments to start in regular expressions:

 if ($ plz_ort = ~ / 
^
\\ d {5} # code
\\ s + # at least 1 blank
[A-Za-zäöüß-] # Place names

$ / x) {}

Thus one can attest to his wonderful and understanding regular expressions therefore complex expressions, even after years ...

I can only recommend that you use this modifier.

Does this modifier in other languages?

In any case, we can thus in Perl clean with complex regular expressions and program read.

0 comments:

Post a Comment