Skip to content

Instantly share code, notes, and snippets.

@Haosvit
Last active November 14, 2019 12:11
Show Gist options
  • Select an option

  • Save Haosvit/f20fc2aa382e2322f35bf5f1b3e7cc06 to your computer and use it in GitHub Desktop.

Select an option

Save Haosvit/f20fc2aa382e2322f35bf5f1b3e7cc06 to your computer and use it in GitHub Desktop.
Regex find text in between delimiter

EX: extract text in between title tags:

const htmlText = '<html><title>Example Title</title><body>abc</body></html>`
const regex = /(?<=<title>).*?(?=\</title>)/;
const matches = htmlText.match(regex);
const title = matches && matches.shift();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment