0

What difference is there between * and \{-} in Vim?

In particular, can one match something the other can't?

Why would one use {-} over *?

tensor
  • 41
  • 2
  • 10
  • 2
    Have a look [here](https://vi.stackexchange.com/a/199) and/or [here](https://stackoverflow.com/q/1305853/9758194) – JvdV Jun 04 '20 at 12:48
  • @phd No, these show how to solve _a_ problem using non-greedy. I am asking whether there is something that can be done with non-greedy that _can't_ be accomplished with other approaches (eg `[^]*` instead of `*`), or is _significantly_ more unwieldy. – tensor Jun 08 '20 at 09:20
  • [This](https://stackoverflow.com/a/1305859/13534897) answer solves the non-greedy problem, even with just as many characters. – tensor Jun 08 '20 at 09:22
  • The [question I linked](https://stackoverflow.com/a/33582669/5889131) should help explain. Reluctant (non-greedy) searches vs greedy ones are less about what they can and cannot match and more about how fast they are. Unoptimized regex can be quite slow over certain strings; reluctant searches can help with that immensely in certain situations. – jeremysprofile Jun 11 '20 at 19:05
  • [This answer](https://stackoverflow.com/a/5319996/13534897) answers most of my question, in particular why one would choose `{-}` over `*`, but not whether they can _always_ match what the other can. – tensor Jun 16 '20 at 13:45
  • Just pointing out that the linked questions have still not answered their difference in power/convenience/speed (a few answers mention that non-greedy can be faster, but nothing concrete); they all answer the qualitative difference. – tensor Jun 16 '20 at 13:48

0 Answers0