python最长匹配_python中最长的匹配

我是python中的新成员。我使用以下格式的2d数组中的数据。

array[0] array[1]

Arkan Adrian Edmondson

Efgan All Rik

'Til Death Do Us Part (Star Trek: Deep Space Nine) Bradley Thompson

'Til Death Do Us Part (Star Trek: Deep Space Nine) David Weddle

Billy Sherrill 'Til I Can Make It on My Own (Deep Space)我想匹配一个文件中的每一行这个字符串,如果匹配这两个数组,然后我想返回该行。

首先,我要在每行中搜索这两个数组。为此,我的尝试是:

def strinMach(domainL, rangeR):

text = ""

filetext = open(File, "r").read()

sentlist = re.split(u'[\n|\r\n]+',filetext)

for i in sentlist:

if domainL in i and rangeR in i:

text = text + i + "\n"

elif (To search for without the parenthesis string from array[0] & array[1]

eg.search with (Til Death Do Us Part Bradley Thompson ) )

elif (To search with some string from array[0] & array[1]

es. search with(Till Death Bradley) or (Do Us Part Thompson))

return text我的第二步是除了括号字符串之外对数组进行筛选(即除了(术语)

)。

第三步用两个数组的子串。

如何继续进行2nd&第三步。

任何形式的帮助将不胜感激。

谢谢!!!!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值