Skip to content

Instantly share code, notes, and snippets.

@suhailgupta03
Created August 17, 2023 15:54
Show Gist options
  • Save suhailgupta03/558b7eda07fd34acc1dc5bc80a2a2f3e to your computer and use it in GitHub Desktop.
Save suhailgupta03/558b7eda07fd34acc1dc5bc80a2a2f3e to your computer and use it in GitHub Desktop.
let string = `Hi! Recently India celebrated its
Independence Day`
// If we want to know if the string ends with a particular
// word / character or not
// we can use the $ sign to check if the string ends with
// a particular word or not
// Like we have ^ to check if the string starts with a character / word
// we have $ to check if the string ends with a character / word
let pattern = /day$/i
console.log(pattern.test(string))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment