Skip to content

Instantly share code, notes, and snippets.

@karupanerura
Created July 6, 2011 23:35
Show Gist options
  • Save karupanerura/1068597 to your computer and use it in GitHub Desktop.
Save karupanerura/1068597 to your computer and use it in GitHub Desktop.
正規表現にマッチする正規表現(未完成)
#!/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