Jump to content

Balanced brackets: Difference between revisions

m
→‎{{header|Perl}}: use Regexp::Common subroutine interface, works with recent versions of Perl
(Add task to aarch64 assembly raspberry pi)
m (→‎{{header|Perl}}: use Regexp::Common subroutine interface, works with recent versions of Perl)
Line 5,897:
}</syntaxhighlight>
 
<code>Regexp::Common::balanced</code> can give such a regexp too (non-brackethere charsvia allowed).a subroutine Its recent versions use the subpattern recursion and are hence also only for Perl 5.10 and up.call)
 
<syntaxhighlight lang="perl">use Regexp::Common 'balancedRE_balanced';
my $re = qr/^$RE{balanced}{-parens=>'[]'}$/;
sub balanced {
return shift =~ $re;RE_balanced(-parens=>'[]')
}
}</syntaxhighlight>
 
Alternative implementation, using straightforward depth counting:
2,392

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.