Regex
- Look Ahead: Assertion for when matching things look ahead and say a match has happened if it occurs after it
- ^ Beginning of String, match if at the start of string
- $ End of String, match if at the end of string
var msg = "Hello World";
console.log(msg.match(/(l.)/g));
console.log(msg.match(/(l.)$/g));
console.log(msg.match(/(l.)(?=o)/g));
console.log(msg.match(/(l.)(?!o)/g));
console.log(msg.match(/(?<=e)(l.)/g));
console.log(msg.match(/(?<!e)(l.)/g));
Named Capture Groups
- You can use named variables to store different regex matches
var msg = "Hello World"
console.log(msg.match(/(?<cap>l.)/).groups);
.all Mode
- Flag to add to regex
- /s = .all Mode
- /u = unicode awareness Mode
- /g
msg.match(/pattern/<flags>)