Reputation: 55
i want to concatenate string with regular expression
my regular expression is
$scope.searchEstimateMeasures = Ne;
var exp = new RegExp("/^" + $scope.searchEstimateMeasures +"/i");
when i am trying to test this regualr expression using
if (exp.test(Net Value))
i am getting an error saying object doesnot support property or method test
i tried using
var exp = new RegExp('/^' + $scope.searchEstimateMeasures +'/i');
but it is returning false.
if i use regex directly(/^ne/i.test(Net Value))
i am getting true.
Upvotes: 0
Views: 43
Reputation: 33880
new RegExp
accept 2 arguments.
The first one is what's usualy be the / /
.
The second one is the flag.
Try that :
var exp = new RegExp('^' + $scope.searchEstimateMeasures, 'i');
Upvotes: 3