schoenwolf-schroeder
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
@VegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish • 11 months ago

Regex flavors

lemmy.world

message-square
33
fedilink
1

Regex flavors

lemmy.world

@VegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish • 11 months ago
message-square
33
fedilink
  • @jaybone@lemmy.world
    link
    fedilink
    0•11 months ago

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

    • @VegOwOtenks@lemmy.worldOP
      link
      fedilink
      0•11 months ago

      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.

      • @jaybone@lemmy.world
        link
        fedilink
        0•11 months ago

        TIL thanks!

    • @mormund@feddit.org
      link
      fedilink
      English
      0•11 months ago

      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
        0•11 months ago

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

Programmer Humor@lemmy.ml

!programmerhumor@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !programmerhumor@lemmy.ml

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.
  • 100 users / day
  • 150 users / week
  • 270 users / month
  • 1.47K users / 6 months
  • 35.7K subscribers
  • 1.26K Posts
  • 17.9K Comments
  • Modlog
  • mods:
  • @AgreeableLandscape@lemmy.ml
  • @cat_programmer@lemmy.ml
  • BE: 0.19.3
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org