$regex = qr/foo/; # should return 0 #### sub captures { my $re = shift; return scalar ( @_ = '' =~ /(?:($re))?/ ) - 1; } #### $regex = qr/(?x) # (comment) (?-x) # (capture) (?x) # (comment)/;