Originally Posted by F16Gaming
So apparently a dash ('-') is equivalent to an asterisk ('*') in Lua patterns, not sure why you'd want to match 0 or more though.
|
A dash is not equivalent to an asterisk.
A plus sign matches at least once, but is greedy and will match as long a string as it can. It will keep going until the pattern no longer matches.
An asterisk is the same as a plus sign, except it can also match nothing.
A minus sign is lazy and matches the shortest string that fulfills the pattern. It stops as soon as it can, rather than continue after the first successful match like the plus sign.
Here's an example to demonstrate why they are very different:
Lua Code:
> ("item:77272:0:0:0:0:0:0:0:11:0:0"):match("(.+):")
item:77272:0:0:0:0:0:0:0:11:0
> ("item:77272:0:0:0:0:0:0:0:11:0:0"):match("(.*):")
item:77272:0:0:0:0:0:0:0:11:0
> ("item:77272:0:0:0:0:0:0:0:11:0:0"):match("(.-):")
item