极简主义的正则表达 [英] minimalist regular expression

查看:78
本文介绍了极简主义的正则表达的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

存在一些工具,程序或一些能够计算最小常规

表达式,即采取一系列常规exoression,最小的

一个相同的匹配?

提前预付

解决方案

[bo ********** @ yahoo.it写道]

存在一些工具,程序或一些能够计算最小常规表达式,即采取一系列常规的exoression,最小的一个做同样的匹配?




def get_minimal_regex(* regexes):

return"。*"

>
:)或者,稍微不那么聪明的屁股:


def get_not_really_minimal_regex(* regexes):

return"(" +" |" .join(regexes)+")"


Trent


-

Trent Mick
Tr****@ActiveState.com

非常好


" bo ********** @ yahoo.it" <博********** @ yahoo.it>写道:

存在一些工具,程序或一些能够计算最小常规表达式,即采取一系列常规exoression,最小的
一个做出相同的匹配?
提前预定




长度? (定义最小):-D。


-

John Small Perl脚本: http://johnbokma.com/perl/

Perl程序员可用: http://castleamber.com/

快乐的客户: http://castleamber.com/testimonials.html


Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance

解决方案

[bo**********@yahoo.it wrote]

Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?



def get_minimal_regex(*regexes):
return ".*"

:) Or, slightly less smart-ass-y:

def get_not_really_minimal_regex(*regexes):
return "(" + "|".join(regexes) + ")"

Trent

--
Trent Mick
Tr****@ActiveState.com


very nice


"bo**********@yahoo.it" <bo**********@yahoo.it> wrote:

Exists some tool, programs or some able to compute the minimal regular
expression, namely ,taking a series of regular exoression, the minimal
one that makes the same matching?
thanx in advance



length? (define minimal) :-D.

--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html


这篇关于极简主义的正则表达的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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