Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
私は、一連の a の後に同数の b の正規表現が続く正規表現を perl で書くように頼まれました。これも私を混乱させます。助けてください
あまりにも老朽化していないバージョンの perl を想定すると、次のようになります。
/(?<ABPAIR>a(?&ABPAIR)?b)/
大まかなアプローチを次に示します。
my $str = 'cabccaabbccabb'; while ($str =~ m/(a+)(b+)/g and length $1 == length $2) { print "match: $1, $2\n"; }