Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Does string.match not tolerate large objects?

Asked by 8 years ago

So apparently I'm getting nil from this matching function. It really doesn't make much sense, but I might be overestimating :match() -- can it not have more than one character between captures?

As you can see, I make a pattern using the setName and wholeName and some hyphens, and try matching it. Nothing is returned though, despite the 'should-be-valid' captures

setName = "BKP"
wholeName = "BREAKpoint"
wholeName = wholeName:lower();
pattern = "(.+)-"..wholeName:lower().."-"..setName:lower().."-(.+)"
print(pattern)
example = "ferroseed-breakpoint-bkp-79"

key, val = example:match(pattern)
print( key )
print( val )

Output

(.+)-breakpoint-bkp-(.+)
nil
nil

1 answer

Log in to vote
1
Answered by
XAXA 1569 Moderation Voter
8 years ago

- is a quantifier. You'll want to escape it with %.

pattern = "(.+)%-"..wholeName:lower().."%-"..setName:lower().."%-(.+)"
0
how did I forget this? randomsmileyface 375 — 8y
Ad

Answer this question