Home > front end >  Get Words After Last Dot in Regex and JS
Get Words After Last Dot in Regex and JS

Time:11-07

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

CodePudding user response:

This should work:

const yeah = 'SampleLibrary/21.0/Best.colour'
const hello = yeah.replace(/^. \./, '');
console.log(hello)

  • Related