小编Gev*_*eze的帖子

Capitalize each first word of a sentence in a paragraph

I want to capitilize the first word after a dot in a whole paragraph (str) full of sentences. The problem is that all chars are lowercase.

I tried something like this:

text = "here a long. paragraph full of sentences. what in this case does not work. i am lost" 
re.sub(r'(\b\. )([a-zA-z])', r'\1' (r'\2').upper(), text) 
Run Code Online (Sandbox Code Playgroud)

I expect something like this:

"Here a long. Paragraph full of sentences. What in this case does not work. I am lost."

python regex python-3.x

2
推荐指数
1
解决办法
71
查看次数

标签 统计

python ×1

python-3.x ×1

regex ×1