How to put quotation marks inside of a string like " "text" " to check

how could I go about checking if a string has quotes in it? like checking if the string is “Text”

1 Like

couldn’t you just use quotes to match it? try being more specific please

string.match('some "text" here', '"text"')

lets say the user writes Game. blah blah, I swap it to game.

But if they write “Game” for example in a table or text or whatever, I dont want it to swap, so I need to check if there is quotes around it

So basically

If player say

“Tea is what i enjoy” then nothing happens
but if player say '“Tea” is what i enjoy" you are getting the Tea from the string?

Not entirely sure I understand what you just said, but ill give an example that I think will make sense

Game.workspace – swaps to game.workspace

“Game is cool” doesnt swap to “game is cool”

So basically it doesnt swap because there are quotes, and thats all?

yes, but this post needs 30 and im not sure how to check if a string has quotes because you cant put quotes in a string thats checking with quotes

You can use " and ’ for change, and it will do the same so basically:

'Hi == “'Hi”
“Hi” == ‘“Hi”’

the issue is, it checks as a string, like here

local foundBadText = string.match(currentLineString, badText)
		local foundGoodText = string.match(currentLineString, '"foundBadText"')

“foundBadText” is seen as a string that says “foundBadText” instead of the text it found

obraz

Use string.find to locate the " or ’ then index the string until you find the second encapsuled " with another string.find

I think you are doing this for Anti Cheat reasons but I have to tell you that Roblox is already doing that for you. A user Input cannot do anything on the server when interrupting the string

im making a demo auto complete plugin

Or,

local function isTextInQuote(text)
    return string.match(text, '^"%s*"$') ~= nil
end

do you mean this?

local idk = 1
local string = “hi my fav number is”…idk

I think there is problem with characters encoding in roblox studio

look, roblox see it as “�”

obraz
obraz

I tried using this just now, unless ive done something wrong its giving me the wrong output

local function isTextInQuote(text)
	return string.match(text, '^"%s*"$') ~= nil
end

print(isTextInQuote('"Game"'))

10:47:15.587 false - Edit

That’s strange. Maybe this is offtopic but for that, try calling string.byte and string.len with '"' being the first argument (don’t copy paste that, write it yourself as it might be related to your problem) and printing the results. You should get 34 and 1.

do you mean this " ’ " aaaaaaaaaaaaaaa

But even your function shows incorrect result

obraz

obraz