-1

I want a regex to extract a value from a string but can´t make it work :( regex is hard!

const myString = "the user id is: [user]10[/user]"

this is my regex

(?:[user])([\s\S]*)(?:[\/user])

but I´m not getting a match

handsome
  • 2,335
  • 7
  • 45
  • 73

1 Answers1

0

Adding matching square brackets literally by adding \ before them will allow obtaining the match id value, like following

(?:\[user\])([\s\S]*)(?:\[\/user\])
frontendgirl
  • 787
  • 5
  • 14