textDoc=
Line 1 "'"Here is my Text which
Line 2 I now have *starred* the words which i would like accounted for"
Line 3 I would like the end result to be Lines 3 Words 6.
Line 4.Python Regular expression **rules** have me trying things that
Line 5.I have listed below. All of them are usable but I would like
Line 6 To understand how to customize it for **production** to use."""
//desiredoutput = Lines 3, Words 3
/* This is because the words: starred, rules, and production are on every
other line and they contain more than 2 vowels all while being the fourth
word on the line.*/
我似乎不能把它放在一起,但一些正则表达式代码,我正在考虑和工作了一点点,迄今为止是:
enumerate, .split. find.All
[aeiou],[aeiou]{2},
textDoc =
numOfLines = len(textDoc.splitlines())
print(numOfLines)
split将单词列表转换为字符串。我想我需要一个新的字符串,每四个字在每一行之前,我数他们来完成我想要的输出行3个字3
我认为在python中不能使用一个regex,因为回溯,下面的解决方案可以使用perl regex,因为它使用控制动词
(*SKIP)
:regex101 link
使用python的最接近的方法由于回溯而不起作用
regex101 link
相关问题 更多 >
编程相关推荐