Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Does string.match not tolerate large objects?

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

✓ Accepted answer

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

pattern = "(.+)%-"..wholeName:lower().."%-"..setName:lower().."%-(.+)"

1 comment

0

how did I forget this?

This discussion is preserved as it was. New answers, comments, and votes are closed.