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

How do I inverse a string pattern?

Asked by
trecept 367 Moderation Voter
5 years ago

For example, if:

for i in string.gmatch(str, "//")

will search for "//" in the string, how would i do the opposite so it returns every part of the string separated by "//"?

0
Could you try -- for i in not string.gmatch(str,"//") RedDuck765 0 — 5y
0
that would error User#24403 69 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

you can use the //(.+) string pattern to get the characters after "//" excluding that, if thats what your looking for.

local str = "//hello world!"

for v in string.gmatch(str,"//(.+)") do
    print(v)
end

hello world!

string patterns

Ad

Answer this question