I have problem with spliting string by "

print(""") --> ERROR: expected ", got <eof>

print("\"") --> "

local stringToSplit = [[hello " there, " what's " up]]
local t = string.split(stringToSplit, "\"")

for k, v in pairs(t) do
    print(k, v)
end
--> 1 hello
--> 2 there,
--> 3 what's
--> 4 up
1 Like

look at the code i posted and you will see i have this, but how to not splitt code by \" (if i dont write it in input, but in script its \\\")

Ahhh, so you want to split by quotes, but not by backslash + quote?

-- imagine this is actual text
local stringToSplit = [[hello " there, \" what's " up]]

local t = stringToSplit:split("\"")

for k, v in pairs(t) do
    print(k, v)
end
--> 1 hello
--> 2 there, \
--> 3 what's
--> 4 up

I had no idea string.split() was in roblox, I was looking for it but didn’t see it so I just used string.find() but anyway OP doesn’t get the concept of escaping but I couldn’t find a better way to explain it.

1 Like

yes, and the outpu is where i am, so i need to dont split it as this do(
1hello
2there,
3whats
4up
)
but to
1hello
2there, " whats
3up

And only way i know is to replace \" to some char and at end the char replace to ", but i dont know what char cant by there by normal or is at least extremly rare

1 Like

Or i can replace it not by char, but by string like “shfkruihafskufskhghfghhulghuydsghuklsklgskulgshfzsfhsdyjfyhgufzggheiqwoqwiqwqpsasklxy,cmxvnfbjgkjw65+998-/-/+5594494999494”(random hits on keyboard), but i dont know how big problem for roblox server ram it will be

In theory, you can create a character using a backslash and 3 numbers:

print("\255") --> �

This might not work, I haven’t tested it:

local stringToSplit = [[hello " there, \" what's " up]]
stringToSplit = stringToSplit:gsub("\\\"", "\255")
local t = stringToSplit:split("\"")
for k, v in pairs(t)
    t[k] = v:gsub("\255", "\"")
    print(k, t[k])
end
--> 1 hello
--> 2 there, " what's
--> 3 up

and what is the limit (one byte (0-255)) or 0-999 or how many i need

The limit is a byte, I tried with "\999" and it errored.
image

image

and do you hnow some blank number (the number of char without any char)

I don’t think there is such a thing, but I’m sure nobody would try to type out , so this would probably be the closest you can get.

i tried it with alt+number and 255 is blank

I believe what OP is trying to say is that for example, when chat is logged and sent through the remote event, it usually has an escape sequence maybe because the string could be invalid without it. He’s trying to get away with it, but he doesn’t know how.

Personally, I would make an API to string.gsub certain parts of the string into more readable without actually touching the string’s result. I consider this parsing.

Anyways, goodluck!

only 1 mistake: i need to divide \ count by 2 replace 2 \ by 1 after replacing \" to " because when escaping i will replace \ by two of them and add one more.
So pls how to write \ in string, i tried it but everytime the code read it as escape chaacter

ok its by escaping backslash (\\)

1 Like