我需要像这样分割一段文字:
//string
s = CS -135IntrotoComputingCS -154IntroToWonderLand...
阵列状
inputarray[0]= CS -135 Intro to computing
inputarray[1]= CS -154 Intro to WonderLand
.
.
是的。 等等; 我试着这样做:
re.compile("[CS]+\s").split(s)
但它还没有准备好甚至打破,即使我尝试类似的东西
重新编译(“[CS]”).split(s)
如果有人能解释一下
虽然
findall
更简单,但是这里也可以使用finditer
可以将
findall
与lookahead regex一起使用,如下所示:正则表达式:
.+?(?=CS|$)
匹配1+任何在下一个位置或行尾有CS
的字符相关问题 更多 >
编程相关推荐