0

I have a link that I want to grab a specific character out of. This is the link in question

"https://example.com/example-myexample/from/MyHouse/to/48DFjjhf333333333/view"

I want to grab the following id 48DFjjhf333333333 from this link using a regular expression. In this link /to/ and /view never change. The only thing that ever changes is the id that you see 48DFjjhf333333333.

I've tried the following regular expression:

\/to(.*?)\/view

This grabs everything along with /to/ and /view as follows /to/48DFjjhf333333333/view. I want to grab just the ID itself 48DFjjhf333333333

1 Answers1

-1

You just need to access the matching group with [1]

console.log("https://example.com/example-myexample/from/MyHouse/to/48DFjjhf333333333/view".match(/\/to\/(.*?)\/view/)[1])
Murat Karagöz
  • 35,401
  • 16
  • 78
  • 107