-1

Trying to search bbcode-style tags with regular expression:

For example, I needed [user=1]John Dow[/user] with regular: [[user=[0-9]+].*?[/user]] But couldn't receive needed result.

Viktorianec
  • 361
  • 6
  • 22

1 Answers1

0

Remove the outer pair of brackets and escape the literal brackets (unlike the range-of-characters brackets)

let pattern = "\\[user=[0-9]+\\].*?\\[/user\\]"
vadian
  • 274,689
  • 30
  • 353
  • 361