如何从Perl正则表达式生成所有可能的排列? [英] How can I generate all possible permutations from a Perl regular expression?

查看:81
本文介绍了如何从Perl正则表达式生成所有可能的排列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道您可以使用 glob 或<例如a href ="http://search.cpan.org/dist/Algorithm-Permute" rel ="nofollow noreferrer"> Algorithm :: Permute -但是如何从正则表达式生成所有可能的排列?

I know you can generate all permutations from a list, using glob or Algorithm::Permute for example - but how do you generate all possible permutations from a regular expression?

我想这样做:

@perms = permute( "/\s[A-Z][0-9][0-9]/" );
sub permute( $regex ) {
    # code - put all permutations of above regex in a list
    return @list;
}

推荐答案

请参见 高级Perl 中的6.5节(PDF).考虑购买印刷书籍:这是一件艺术品.

See Section 6.5 (PDF) in Higher Order Perl. Consider buying the print book: It is a work of art.

Regexp :: Genex ://search.cpan.org/"rel =" nofollow noreferrer> CPAN .

There is also Regexp::Genex on CPAN.

这篇关于如何从Perl正则表达式生成所有可能的排列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆