I’v just use it as below in setup,but it just get e printed,Please tell me what’s wrong with it.
yll="hello"
t=string.match(yll,"e")
print(t)
I’v just use it as below in setup,but it just get e printed,Please tell me what’s wrong with it.
yll="hello"
t=string.match(yll,"e")
print(t)
From the manual:
string.match (s, pattern [, init])
Looks for the first match of pattern in the string s. If it finds one, then match returns the captures from the pattern; otherwise it returns nil. If pattern specifies no captures, then the whole match is returned. A third, optional numerical argument init specifies where to start the search; its default value is 1 and can be negative.
You didn’t provide a capture, so all of your pattern is treated as the capture. Your pattern is “e”, and as it is found in the string it is returned.
What did you want it to do?
What do you want it to do?
Look in a lua manual for patterns
For example
t=string.match(yll,“e%a+”)
Will print ello