lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I ran into this today, and while I tried to explain it away, I have to admit I am mildly confused.

Why does the following match the entire string "/dev/myprog/image/xyz/"?

=string.match('/dev/myprog/image/xyz/', '(/.-/)$)

The documentation states that a - (minus) matches the shortest possible sequence.

I hadn't given this any thought until today, as I normally would have written '.+(/.-/)$'. That would have yielded the correct result of '/xyz/'. When discussing it with a coworker, though, he raised the point that with the final / (slash) anchored at the end of the string, the shortest possible matching sequence should be '/xyz/'.

I can buy into that argument.  What are we missing?