Not exactly quotation marks, but I simply want to search for a pair of any single or series of characters, get the substring, and print it out. I wanted it so that any string can be used to find a substring of a string, not just quotation marks. For example, I want to search for a pair of !!
's in a string like This is a !!WARNING!!
. I want to print only WARNING
while being able to use the same code on different strings without even changing the code itself.
I do have a solution in mind, but it seems to be way too much code. Is this the right solution, or is there a better way to do this?
local String = "I want to get ``this`` part."
local Indicator = "``"
local Part1_Start, Part1_End = string.find(String, Indicator)
local Part2 = if Part1_End then string.find(String, Indicator, Part1_End) elseif Part1_Start then string.find(String, Indicator , Part1_Start) else nil
if (Part1_End or Part1_Start) and Part2 then
print(String:sub((Part1_End or Part1_Start) + 1, Part2 - 1))
end