I am new to regular expressions.
The following code works as expected, first prints βtrueβ and then βfalseβ, the backslash before the period that eludes it:
var pattern = new RegExp(/\./);
document.write(pattern.test("."));
document.write(pattern.test("a"));
But why is the following print "false":
var pattern = new RegExp(/\b\./);
document.write(pattern.test("."));
The period, after all, is at the beginning of the line.
source
share