Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我有一段文字,即
title="gun control" href="/EBchecked/topic/683775/gun-control"
并想创建一个匹配的正则表达式(见<>下文)
<>
title="<1 word or many words separated by a space>" href="/EBchecked/topic/\w*/\S*"
我如何解决中的那部分<>?
以下正则表达式将匹配 1 个单词或多个由空格分隔的单词:
\w+( \w+)*
这里的“单词”被认为由字母、数字和下划线组成。如果您只想允许字母,您可以使用[a-zA-Z]+( [a-zA-Z]+)*.
[a-zA-Z]+( [a-zA-Z]+)*