• GenderNeutralBro@lemmy.sdf.org
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 days ago

    I have lots of places I can use regex to match strings, but otherwise have no easy way to say “match any in list”.

    Is it stupid? Sure. But I can’t fix the umpteen web consoles I manage; I have to work with them as they are.

    • HotChickenFeet@sopuli.xyz
      link
      fedilink
      arrow-up
      3
      ·
      edit-2
      2 days ago

      (?: strings|stringb|stringc)

      Is valid regex given a list of strings to match, no?

      Is the advantage here some performance gain or potential to use fewer characters depending on the list?

      Edit: I see elsewhere it’s specifically so you can match against a long list of specific IPs - so maybe a bit of both.

    • thingsiplay@lemmy.ml
      link
      fedilink
      arrow-up
      2
      ·
      2 days ago

      I see. Even if I have no use case for it personally, I want you to thank you for sharing. Its probably a niche use case, but always interesting to see what problems others try to solve and how they did it. The code is actually smaller than I expected.