开发者

Complex regular expression

开发者 https://www.devze.com 2023-01-28 07:48 出处:网络
Consider the following regular expression : ^[:;][-^]\\)$ List all the strings that exactly ma开发者_如何学Ctch this expression or, if there are more than ten such strings, describe them.Assuming t

Consider the following regular expression :

^[:;][-^]\)$

List all the strings that exactly ma开发者_如何学Ctch this expression or, if there are more than ten such strings, describe them.


Assuming the close paren is spurious, here is a slick solution:

% echo {':',';'}{'-','^'}\)
:-) :^) ;-) ;^)

Which is of course:

% perl -le 'print for <{:,;}{-,^})>'
:-)
:^)
;-)
;^)

Isn’t that cool?

And then of course, there's this:

              #!/usr/bin/perl
          use            5.010                                                                                     ;
        $stdout = 124.102.109.116;
                 open
                stdout                                                                                             ;        
              use    less 
  ${"\42"}         =         "\54"                                                                                 ;
                  say 
                  for 
                 @224                                                                                              = 
                  eval 
                  join 
                /\/\/\/∖/                                                                               => 
                   map 
                {"<$_>"} 
                  join 
                /\/\/\/∖/                                                                               => 
                   map 
                {"{@$_}" } 
           [qw{  |  [     }   ]                                                                                    =>
       [qw{    :  ;  % #     }   ]                                                                                 =>
   [qw{      ^  =  *  _  ~    }    ]                                                                               =>
[qw{     /  v  )  |  o   3  I   }    ]  

which delightfully produces this:

|:^/ |:^v |:^) |:^| |:^o |:^3 |:^I |:=/ |:=v |:=) |:=| |:=o |:=3
|:=I |:_/ |:_v |:_) |:_| |:_o |:_3 |:_I |:~/ |:~v |:~) |:~| |:~o
|:~3 |:~I |;^/ |;^v |;^) |;^| |;^o |;^3 |;^I |;=/ |;=v |;=) |;=|
|;=o |;=3 |;=I |;_/ |;_v |;_) |;_| |;_o |;_3 |;_I |;~/ |;~v |;~)
|;~| |;~o |;~3 |;~I |%^/ |%^v |%^) |%^| |%^o |%^3 |%^I |%=/ |%=v
|%=) |%=| |%=o |%=3 |%=I |%_/ |%_v |%_) |%_| |%_o |%_3 |%_I |%~/
|%~v |%~) |%~| |%~o |%~3 |%~I |#^/ |#^v |#^) |#^| |#^o |#^3 |#^I
|#=/ |#=v |#=) |#=| |#=o |#=3 |#=I |#_/ |#_v |#_) |#_| |#_o |#_3
|#_I |#~/ |#~v |#~) |#~| |#~o |#~3 |#~I [:^/ [:^v [:^) [:^| [:^o
[:^3 [:^I [:=/ [:=v [:=) [:=| [:=o [:=3 [:=I [:_/ [:_v [:_) [:_|
[:_o [:_3 [:_I [:~/ [:~v [:~) [:~| [:~o [:~3 [:~I [;^/ [;^v [;^)
[;^| [;^o [;^3 [;^I [;=/ [;=v [;=) [;=| [;=o [;=3 [;=I [;_/ [;_v
[;_) [;_| [;_o [;_3 [;_I [;~/ [;~v [;~) [;~| [;~o [;~3 [;~I [%^/
[%^v [%^) [%^| [%^o [%^3 [%^I [%=/ [%=v [%=) [%=| [%=o [%=3 [%=I
[%_/ [%_v [%_) [%_| [%_o [%_3 [%_I [%~/ [%~v [%~) [%~| [%~o [%~3
[%~I [#^/ [#^v [#^) [#^| [#^o [#^3 [#^I [#=/ [#=v [#=) [#=| [#=o
[#=3 [#=I [#_/ [#_v [#_) [#_| [#_o [#_3 [#_I [#~/ [#~v [#~) [#~|
[#~o [#~3 [#~I                                                            
0

精彩评论

暂无评论...
验证码 换一张
取 消