Added new test cases and corrected the solution for positive and negative lookahead for ensuring that strings beginning with numbers are not accepted (#37485)

* Added new test case '8pass99' for positive and negative lookahead

* Changed the pwRegex to reflect the new solution

* Updated the pwRegex to reflect the latest solution as on forum

* Added another test case to catch "/^(?=\w{6,})(?=\D*\d{2})/" solution
pull/37750/head^2
Divyanshu 2019-11-25 03:41:20 +05:30 committed by Manish Giri
parent deb24f77b6
commit a987245e18
1 changed files with 7 additions and 1 deletions

View File

@ -58,6 +58,12 @@ tests:
testString: assert(!pwRegex.test("123"));
- text: Your regex should not match <code>"1234"</code>
testString: assert(!pwRegex.test("1234"));
- text: Your regex should not match <code>"8pass99"</code>
testString: assert(!pwRegex.test("8pass99"));
- text: Your regex should not match <code>"12abcde"</code>
testString: assert(!pwRegex.test("12abcde"));
```
@ -85,7 +91,7 @@ let result = pwRegex.test(sampleWord);
```js
var pwRegex = /(?=\w{6})(?=\D*\d{2})/;
var pwRegex = /^(?=\w{6})(?=\D+\d{2})/;
```
</section>