Given a sentence,
Scheme is such a bizarre programming language.
So any sentence that contains is
and language
should return true. I found |
means or
, but couldn't find any symbol means and
.
Thanks,
Given a sentence,
Scheme is such a bizarre programming language.
So any sentence that contains is
and language
should return true. I found |
means or
, but couldn't find any symbol means and
.
Thanks,
Try the following regex:
\bis\b.*\blanguage\b
This one will match if the two words appear in exactly that order. \b (word boundary) means that the words are standalone.
You can use the idiom.
(?=expr)
For example,
(?=.*word1)(?=.*word2)
For more details, please refer to this threads.
Kinda ugly, but it should work (regardless of the how 'is' and 'language' are ordered):
(.*is.*language.*|.*language.*is.*)
In c# (and I know you didn't ask about c#, but it illustrates how this can be done much quicker)...
string s = "Scheme is such a bizarre programming language.";
if ((s.Contains(" is") || s.Contains("is ")) &&
(s.Contains(" language") || s.Contains("language ")))
{
// found match if you got here
}
Regexs can be slow and hard to parse by someone who is reading your code. Simple string matches are quicker generally.
EDIT: This doesn't care about the order of the words and works for simple whitespace only
Try this one if you don't care about the order of the words in the sentence:
\bis\b.*\blanguage\b|\blanguage\b.*\bis\b