lua-users home
lua-l archive

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Cawley wrote:
> With the pattern '(/.-/)$', you're asking Lua to match a forward
> slash, then match as few characters as possible such that what then
> follows is a forward slash followed by the end of the string. After
> the first forward slash in the pattern is matched against the first
> forward slash in the input, the minimum amount which can be captured
> to get a forward slash followed by the end of the input is the entire
> of the input.

I note that this:

string.match('/dev/myprog/image/xyz/', '(/[^/]-/)$')

...produces the expected output.

I'll admit that I've never really found - very intuitive, for this sort
of reason. I tend to prefer using + and * instead with explicit rejects
for invalid input, like above.

- --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│ "There is nothing in the world so dangerous --- and I mean *nothing*
│ --- as a children's story that happens to be true." --- Master Li Kao,
│ _The Bridge of Birds_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFK631nf9E0noFvlzgRAgn6AJ0T+XCT29KrKrIG/XIxNlI8bAgr8QCgziDF
4gCPQnrbRc78seS7JotJjgk=
=QhNE
-----END PGP SIGNATURE-----