regex - 需要 RE 才能在行尾前仅提取大写单词集
问题描述
我想创建一个正则表达式,它将在一行上提取一组大写单词(由空格分隔)。
例如,在本文中
TOPIC ONE
Description of this topic, one CAPITAL word
TOPIC NUMBER TWO
Description of this topic two CAPITAL word
我只需要选择主题一和主题二,而不是大写这个词。
我尝试了以下 RE
\b[A-Z]+\b
能够单独提取大写单词
我也试过
\b[A-Z]+\ \b
但它会选择除最后一个大写单词之外的所有内容。
我想确保 RE 始终只选择多个单词。
这是要测试的示例文本:
CHIEF COMPLAINT Weakness inability to talk
HISTORY OF THE PRESENT ILLNESS This is a yearold
AfricanAmerican male with a history of hypertension who was
in his usual state of health
FAMILY HISTORY Unknown
SOCIAL HISTORY The patient lives
PHYSICAL EXAMINATION ON ADMISSION During the five minute
examination the patient became progressively less responsive
and then vomited requiring intubation and paralytics during
the examination
解决方案
推荐阅读
- date - 如果单元格不为空,则计算两个日期之间的天数并将其中一个日期交换为另一个日期 - 谷歌表
- react-native - React Native Maps 转到标记
- ios - Swift:来自故事板的 iOS 多语言集标签文本
- django - 如何限制草莓-graphql(Django实现)中的查询深度?
- android - Android onDestroy() 方法未按预期工作
- laravel - Laravel Scout - 刷新命令不起作用
- amazon-web-services - AWS EMR 和 Apache Atlas - Atlas 元数据的持久存储
- vb.net - 我需要在 VB Windows 服务中使用 AspNetUser Validation
- python - 获取 conda 环境中用户安装包的列表(无依赖项)
- php - 允许在 Wordpress 上注册的用户无需通过电子邮件发送给用户的链接确认激活即可登录