# Write a pattern to match sentence endings: sentence_endings sentence_endings = r"[___]" # Split my_string on sentence

动态 未结 0 130
小小草
小小草 LV1 2023年9月23日 23:40 发表
Here's the completed code: ``` import re my_string = "Let's write RegEx! Won't that be fun? I sure think so. Can you find 4 sentences? Or perhaps, all 19 words?" # Write a pattern to match sentence endings: sentence_endings sentence_endings = r"[.?!]" # Split my_string on sentence endings and print the result print(re.split(sentence_endings, my_string)) # Find all capitalized words in my_string and print the result capitalized_words = r"\b[A-Z]\w+" print(re.findall(capitalized_words, my_string)) # Split my_string on spaces and print the result spaces = r"\s+" print(re.split(spaces, my_string)) # Find all digits in my_string and print the result digits = r"\d+" print(re.findall(digits, my_string)) ``` The code uses regular expressions to split a string into sentences, find all capitalized words, split the string into words, and find all digits. The `re`
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复