i want to check for certain regex expression to make sure some string is followed by '::' and some number. The number can be between 1 and 999999999999.
for example: 'ACME LOCK & KEY::42443' should pass where 'ABC Inc.' should fail.
any help?
i want to check for certain regex expression to make sure some string is followed by '::' and some number. The number can be between 1 and 999999999999.
for example: 'ACME LOCK & KEY::42443' should pass where 'ABC Inc.' should fail.
any help?
Try this:
/::[1-9]\d{0,11}$/.test(str)
This will return true for every string that ends with ::
followed by an integer between 1 and 999999999999 inclusive.
Here, this will match a string that ends in ::
followed by 1-12 digits.
/^.+::[1-9]\d{0,11}$/.test(stringToTest)
This also checks to make sure there is a string of at least 1 character prior to the ::
Tests:
FAIL: asdf
PASS: asdf::123
FAIL: asdf::
FAIL: asdf::0
PASS: asdf::999999999999
FAIL: asdf::9999999999999
FAIL: ::asdf
FAIL: ::999