我正在尝试使用ng-pattern
在文本框中验证IP地址CODE:
<input name="machinestodiscover" type="text" ng-model="machinestodiscover" ng-minlength="7" ng-maxlength="15" ng-pattern="/\b([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})\b/" required>
<span ng-show="conditionForm.machinestodiscover.$error.required" class="help-block" style="display:inline;">*Machines To discover Required</span>
<span ng-show="conditionForm.machinestodiscover.$error.pattern" class="help-block" style="display:inline;">*IP Pattern Wrong.</span>
我面临的问题是它甚至接受了1.1.1.1.1.1.1的价值。
中的表达式截图:
我的正则表达式/ ng-pattern
有什么问题答案 0 :(得分:2)
问题出在.
这是字边界。即^([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})[.]([0-9]{1,3})$
也与单词边界相匹配。
改为使用锚点
^
$
将正则表达式锚定在字符串的开头。SELECT Positionname,
Count(NoOfApplication) AS NoOfApplications,
Max(COUNT1) AS Qualified,
Max(COUNT2) AS Diqualified
FROM APPLICATION A
CROSS APPLY (SELECT Count(NoOfApplication) AS COUNT1
FROM APPLICATION A
WHERE EligibleStatus1 = 1
AND EligibleStatus2 = 1)B
CROSS APPLY (SELECT Count(NoOfApplication) AS COUNT2
FROM APPLICATION A
WHERE EligibleStatus1 = 2
OR EligibleStatus2 = 2)C
GROUP BY PositionName
将正则表达式锚定在字符串的末尾