我正在尝试解决使用正则表达式匹配部分字符串的问题。
例如,如果我的
bigString = 'I am going to school. Which one, said one of the friend. Well, I dont know but it is owned by Beats Ltd., and I kind of like it and our principal K.L.Doubies is extremely good. I cant imagine going to any other school.'
如果我要提取一部分以点开头但在至少2个字符后不包含点且包含“主要”字词的字符串。简而言之,我需要一个完整的句子。因此,在我的bigString
中,我想匹配-''. Well, I dont know but it is owned by Beats Ltd., and I kind of like it and our principal K.L.Doubies is extremely good.''
这是我的尝试:
r'\.((?!\w\w+\.).)*principal.*?\w\w+\.'
在(?!\w\w+\.)
中,我很想使用异常来忽略Ltd. Co. Dr.之类的词。