[英]How to regex Capital Letter without space before | Python 3
I'm using regex to find specific text within a web page. 我正在使用正则表达式在网页中查找特定文本。 My pattern looks something similar like this:
我的模式看起来像这样:
([a-zA-Z0-9 ,.:;]+)
How do I find text before a capital letter without a space before? 如何在大写字母前找到没有空格的文本? For example, from:
例如,来自:
test Test
the following should be found: test Test
应该找到以下内容:
test Test
Where from: 来自哪里:
testTest
the following should be found: test
Anyone an idea on how to accomplish this? 应该找到以下内容:
test
关于如何实现此目标的任何想法?
Thanks in advance and cheers, Dominik 在此先感谢您的欢呼,Dominik
You could try something like this( https://regex101.com/r/GIEtVg/1 ): 您可以尝试这样的事情( https://regex101.com/r/GIEtVg/1 ):
[a-z]+?(?=[A-Z])|[a-z]*?\s[A-Z][a-z]+
Probably not the best solution but it works 可能不是最好的解决方案,但它可行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.