Can you actually name capture groups, or this means how you can refer to them by number?

@mormund@feddit.org
link
fedilink
English
12M

In modern languages you can name them with labels as well yes. Not sure about the syntax right now. Something like (?label:…) I think

qaz
link
fedilink
42M

It’s (?<NAME>...) and those are the named capture groups referred to in the post.

You can use backreferences \1 \2 etc. but you can also give them names explicitly.
it looks like this: (?<name>inner-regex)
Some flavors support it, kotlins doesn’t apparently.

TIL thanks!

Create a post

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

  • Posts must be relevant to programming, programmers, or computer science.
  • No NSFW content.
  • Jokes must be in good taste. No hate speech, bigotry, etc.
  • 1 user online
  • 120 users / day
  • 257 users / week
  • 744 users / month
  • 3.72K users / 6 months
  • 1 subscriber
  • 1.48K Posts
  • 32.6K Comments
  • Modlog