【发布时间】:2017-05-31 06:58:59
【问题描述】:
我的 UI 要求输入 User_ID 和 Supplier_ID,我想要一个字符串验证接受 Supplier_ID 的输入,如下所示:
1st scenario: 123456
2nd scenario: 123456,098765
3rd scenario: 123456,098765,345678
虽然它不应该接受如下输入:
1st scenario: Any number less than 6 digits like 123
2nd scenario: Any number more than 6 digits 1234567
3rd scenario: Inputs with comma in the end or even at the beginning - 123456,098765,345678, or ,098765,345678
我将在下面的查询中使用 Supplier_ID 的输入:
UPDATE ABC.Items
SET Crit_Limit = 'Y'
WHERE User_ID = 'userID'
AND Supplier_ID in (suppID)
变量 suppID 将携带来自 UI Supplier_ID 的输入,因此查询将如下所示:
UPDATE ABC.Items
SET Crit_Limit = 'Y'
WHERE User_ID = '007'
AND Supplier_ID in (123456,098765,345678)
无论如何,Supplier_ID 字段的长度为 6,并且必须是数字。
提前致谢!
【问题讨论】:
-
Java
!=Javascript -
你尝试过什么?
-
我试过这个 [0-9]{6} 但它只会将我限制为 6 位数,当我输入例如 123456,098765 时,程序会给我一个错误,因为它只会满足6 位输入。如何在表达式中使用逗号?
-
([0-9]{6},)*[0-9]{6} -
非常感谢安迪!这个有效! :) ([0-9]{6},)*[0-9]{6} 谢谢!谢谢!
标签: javascript java angularjs db2 db2-400