76
rated 0 times
[
80]
[
4]
/ answers: 1 / hits: 37592
/ 9 Years ago, fri, may 8, 2015, 12:00:00
I'm trying to write this regEx (javascript) to match word1
and word2
(when it exists):
This is a test. Here is word1 and here is word2, which may or may not exist.
I tried these:
(word1).*(word2)?
This will match only word1
regardless if word2
exists or not.
(word1).*(word2)
This will match both but only if both exists.
I need a regex to match word1 and word2 - which may or may not exist.
More From » regex