我有一个有效的Java Regex,除了我的逻辑,它是贪婪的。
目的是仅匹配包含关键字的4个单词,而不是之前或之后的空格或单词或字符。
示例文字:
Chief Complaint
· "Lorem ipsum dolor sit amet.."
· "Lorem ipsum dolor sit amet.."
History of Present Illness
Lorem Ipsum is simply dummy text of the printing and typesetting
Review of Systems
Donec luctus metus: Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Donec luctus metus: Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Past Medical History
· Contrary to popular belief, Lorem Ipsum is not simply random text
· Contrary to popular belief, Lorem Ipsum is not simply random text
Social History
· "Lorem ipsum dolor sit amet.."
· "Lorem ipsum dolor sit amet.."
Surgical History
· "Lorem ipsum dolor sit amet.."
Family History
· "Lorem ipsum dolor sit amet.."
Current Meds
· "Lorem ipsum dolor sit amet.."
My Regex:
^[\s]*(?:\b(?:[Ss]ubjective|[Oo]bjective|[Aa]llergy|[Ll]aboratory|[Ll]ab|[Aa]llergie|[Ii]mpression|[Pp]lan|[Hh]istory|[Mm]ed|[Ee]xam|[Vv]ital|[Aa]ssessment|[Pp]roblem|[Cc]omplaint|[Ii]llness|[Ss]ystems|List|[Cc]hief|of|[Cc]urrent|[Pp]resent|[Ii]llness|[Pp]ast|[Mm]edica|[A-Za-z]|Comment:)+s?\b[\s]*){1,4}$
在线测试人员链接:
http://java-regex-tester.appspot.com/regex/85b4429f-59ed-4a0c-b016-f7a6ddce5344
你能建议编辑吗?
答案 0 :(得分:0)
看起来您的文字格式一致。你为什么不这样做?
array.map({ (first, second), (third, fourth) in ... })
array.map({ ((first, second), (third, fourth)) in ... })
捕获任何只有7个或最多8个前导空格的东西。