Q. Consider the following statements var text = "testing: 1, 2, 3"; // Sample text var pattern = /\d+/g In order to check if the pattern matches with the string “text”, the statement is
-
(A)
text==pattern
-
(B)
pattern.test(text)
-
(C)
text.test(pattern)
-
(D)
text.equals(pattern)
β
Correct Answer: (B)
pattern.test(text)