Campfyre
  • Communities
  • Create Post
  • Create Community
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
VegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish · 1 年前

Regex flavors

lemmy.world

message-square
28
fedilink
393

Regex flavors

lemmy.world

VegOwOtenks@lemmy.world to Programmer Humor@lemmy.mlEnglish · 1 年前
message-square
28
fedilink
  • jaybone@lemmy.world
    link
    fedilink
    arrow-up
    8
    ·
    1 年前

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

    • VegOwOtenks@lemmy.worldOP
      link
      fedilink
      arrow-up
      24
      ·
      1 年前

      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
        arrow-up
        2
        ·
        1 年前

        TIL thanks!

    • mormund@feddit.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 年前

      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@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        1 年前

        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: [email protected]

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.
Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 292 users / day
  • 762 users / week
  • 2.57K users / month
  • 8.35K users / 6 months
  • 2 local subscribers
  • 37K subscribers
  • 1.37K Posts
  • 34.3K Comments
  • Modlog
  • mods:
  • cat_programmer@lemmy.ml
  • AgreeableLandscape@lemmy.ml
  • BE: 0.19.7
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code
  • join-lemmy.org