lua-users home
lua-l archive

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

On 2017-09-05 04:43 PM, Lev wrote:
Hi all,

I have some issues with string.find().

What do I miss?

$ lua5.3
Lua 5.3.3  Copyright (C) 1994-2016, PUC-Rio
return string.find(str, '--d8eb6ad5-707f')
return string.find(str, '--d8eb6ad5-')
1	9
return string.find(str, '--d8eb6ad5-7')
I've tried that with 5.1, 5.2 and 5.3. All on Debian Stable, and also with 5.1 on some embedded platform on LEDE 17.01.1. Same result.

Any help welcome.

> return string.find(str, '--d8eb6ad5')
1    10

That's because - has a special meaning in Lua patterns:

A pattern item can be

- a single character class followed by '-', which also matches zero or more repetitions of characters in the class. Unlike '*', these repetition items will always match the shortest possible sequence;


Disclaimer: these emails may be made public at any given time, with or without reason. If you don't agree with this, DO NOT REPLY.