-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpathChecker.js
More file actions
25 lines (19 loc) · 821 Bytes
/
pathChecker.js
File metadata and controls
25 lines (19 loc) · 821 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// function isJS(path) {
// const lastWord = /\w+$/
// console.log('lastWord', lastWord)
// console.log(path.match(lastWord))
// }
// console.log(isJS('/users/user.jsx')) //➞ true
// console.log(isJS('/users/user.js')) //➞ true
// console.log(isJS('/users/user.ts')) //➞ false
const text = 'A quick fox'
const regexpLastWord = /\w+$/
console.log(text.match(regexpLastWord))
// expected output: Array ["fox"]
// /\bm/ matches the "m" in "moon".
// /oo\b/ does not match the "oo" in "moon", because "oo" is followed by "n"
// which is a word character.
// /oon\b/ matches the "oon" in "moon", because "oon" is the end of the string,
// thus not followed by a word character.
// /\w\b\w/ will never match anything, because a word character can never be
// followed by both a non-word and a word character.