0

I have this regular expression that I wrote, which extracts text in between tags like "#<string to extract>":

"#<(.+?)>"

I need to make sure that the length of the string I'm extracting is 6 and my current solution is checking the length of the string that I extracted with an if statement. I would like to replace this with a regex instead. How could I modify "#<(.+?)>" to make sure it is 6 characters when extracted?

Unmitigated
  • 76,500
  • 11
  • 62
  • 80
sb2
  • 29
  • 5

1 Answers1

0

You can use curly braces to specify the length of the match.

#<(.{6})>
Unmitigated
  • 76,500
  • 11
  • 62
  • 80