• lemmonade@lemm.ee
    link
    fedilink
    arrow-up
    11
    arrow-down
    2
    ·
    11 months ago

    You could also say that down should not complete to download since those are completely different strings and you shouldn’t expect one to get you the other.

      • Honytawk@lemmy.zip
        link
        fedilink
        arrow-up
        6
        arrow-down
        2
        ·
        11 months ago

        Substring is not string.

        If they were interchangeable, then “D” & “d” should be too.

        • Feyter@programming.devM
          link
          fedilink
          arrow-up
          2
          ·
          11 months ago

          down matches down* because * also includes empty string. Also download matches down*

          D matches D* but d is not matching D* because D is a different character than d.

          • lemmonade@lemm.ee
            link
            fedilink
            arrow-up
            1
            ·
            edit-2
            11 months ago

            but why do we have to match specifically against substr*? it’s not a law of nature, we could also match against the regex (?i)substr(?-i).*

            not saying that one option is necessarily better, but I don’t see a good reason for which any one of these options would be terrible

            • Feyter@programming.devM
              link
              fedilink
              arrow-up
              1
              ·
              edit-2
              11 months ago

              Because usability. If you have the files down down1 down2 downxyz and download and the user only knows that it was “something with down” it’s best to show the user everything matching “down*” and let the user decide what’s the correct one.

              Also I’m not sure but wouldn’t your expression show everything if only one character would be entered?

              And again I don’t see this solving anything if the entered string actually contains other characters then what’s in the file (D != d)

              Yes one could argue that some form of advanced algorithm or even AI could be used to identify such use case like download and Download but this is programming Humor, not linguisic Humor.