Reputation: 5141
I have a following regex:
[.][a-zA-Z]
So, if there's a string like .row
then it will select .r
. What I want is to be able to select only the dot i.e. regex selects only the dot(.
)!
Upvotes: 0
Views: 4636
Reputation: 37775
You need to use positive lookahead
let str = `.row`
console.log(str.match(/\.(?=[A-Za-z])/g))
Upvotes: 2
Reputation: 739
If you want to just select the dot, escape your .
with \.
since .
means any single character. And don't include [a-zA-Z]
[\.]
https://regex101.com/r/mJ9A6u/1/
Upvotes: 0