Created
July 6, 2011 23:35
-
-
Save karupanerura/1068597 to your computer and use it in GitHub Desktop.
正規表現にマッチする正規表現(未完成)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use feature qw/say/; | |
my $char = qr{[^\|\+\*\(\)\[\}\\]|(?:\\[\|\+\*\(\)\[\}\\])}; | |
my $str = qr{(?:${char}(?:[\+\*\?][^\+\*\?]?)?)+}; | |
my $char_set = qr{\[${char}+\]}; | |
my $regexp = qr{(?:(?:\(\R(?:\|\R)*\))|(?:\R(?:\|\R)*)|(?:${str}|${char_set})+)*}; | |
sub regexp_parser { | |
my $regexp_str = shift; | |
say $regexp_str =~ $regexp ? 'match!' : 'unmatch!'; | |
} | |
# (.*) | |
# (.+) | |
regexp_parser('(.(.hoge|fuga))'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment