Reputation: 7755
How do I get the word after the last dot using Regex and JS?
const yeah = 'SampleLibrary/21.0/Best.colour'
const hello = yeah.replace('(?<=\.|^)[^.]+$')
console.log(hello)
EXPCTECTED OUTPUT
colour
Upvotes: 1
Views: 39
Reputation: 11070
This should work:
const yeah = 'SampleLibrary/21.0/Best.colour'
const hello = yeah.replace(/^.+\./, '');
console.log(hello)
Upvotes: 1