简体   繁体   English

如何在没有空格的情况下对大写字母进行正则表达式| Python 3

[英]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.

相关问题 当且仅当前一个字母不是大写字母时,才如何在大写字母前插入空格? - How do I insert space before capital letter if and only if previous letter is not capital? Python:在大写字母前查找小写/数字的正则表达式条件 - Python: regex condition to find lower case/digit before capital letter 使用正则表达式在 dataframe 或 python 中的列之前添加空格 - Add space before capital letters in a dataframe or column in python using regex Python Regex - 检查大写字母后面的大写字母 - Python Regex - checking for a capital letter with a lowercase after Python 正则表达式拆分数字和大写字母 - Python regex to split both on number and on capital letter 当且仅当前一个字母也不也是大写的Pythonic方式才能在大写字母前添加空间 - Pythonic Way to Add Space Before Capital Letter If and Only If Previous Letter is Not Also Capital 如何在大写字母前添加新行? - How to add a new line before a capital letter? 识别罗马数字后跟“.”、空格和大写字母。 (正则表达式) - Recognize roman numeral followed by '.', space and then capital letter. (RegEx) 在第二个或第三个大写字母python之后插入空格 - Insert space after the second or third capital letter python 如果没有正则表达式的python中特定单词没有空格,如何在前后添加空格 - How to add space before or after if there is no space for a particular word in python without regex
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM