Last active
March 5, 2018 03:16
-
-
Save a1exlism/7234f2ade88216553e00f8d69f1fb8ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let strA = 'JackChen is my friend.'; | |
let strB = 'JackBlack is not my friend.'; | |
// x(?=y) x is followed by y | |
let regX = /Jack(?=Chen)/g; | |
console.log(regX.test(strA)); // true | |
console.log(regX.test(strB)); // false | |
// x(?!y) x is NOT followed by y | |
let regY = /Jack(?!Chen)/g; | |
console.log(regY.test(strA)); // false | |
console.log(regY.test(strB)); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment