有一个正则表达式可以在一个句子中找到两个不同的单词吗? [英] Is there a regular expression to find two different words in a sentence?
本文介绍了有一个正则表达式可以在一个句子中找到两个不同的单词吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
reg_ex_match(A,B,A和B的句子)= true
reg_ex_match(C,D,A和B的句子)= false
另请参阅问题
解决方案
对于真正的单词:
\bA\b。+ \bB\b | \bB\b。+ \bA\b
Is there a regular expression to find two different words in a sentence? Extra credit for an expression that works in MS Visual Studio 2008 :)
For example:
reg_ex_match(A, B, "A sentence with A and B") = true
reg_ex_match(C, D, "A sentence with A and B") = false
See also this related question
解决方案
For real words:
\bA\b.+\bB\b|\bB\b.+\bA\b
这篇关于有一个正则表达式可以在一个句子中找到两个不同的单词吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文