How do i convert this **text** into this <b>text</b>?

  1. What do you want to achieve? Keep it simple and clear!
    I want to convert this **text** into <b>this</b> to be able to use the rich text inside of roblox, since roblox only supports tags and not this **.

  2. What is the issue? Include screenshots / videos if possible!
    The issue is I have no clue how to do this.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yeah, but none of them helped me in any way.

local newString = "<b>Hello world!</b>"
local newString = string.gsub(newString, "<b>", "**")
local newString = string.gsub(newString, "</b>", "**")
print(newString)
--output **Hello world!**

literally the exact opposite of what im trying to do lol

have it the other way then? he basically showed u exactly how to do it

local newString = "**Hello world!*"
local newString = string.gsub(newString, "^**", "<b>")
local newString = string.gsub(newString, "**$", "</b>")
print(newString)
--output <b>Hello world!</b>

This would end up being "<b>Hello world!<b>" because the first gsub would replace both occurrences of "**" with "<b>".

it prints this <b>test**normal text**hu**more normal text</b> it might work with one word but it doesnt support more. i have this

local stri = "**test**normal text**hu**more normal text"
local spl = stri:gsub("** **", "</b> <b>")
print(spl)

but it prints </b> <b>test</b> <b>normal text</b> <b>hu</b> <b>more normal text

local newString = "**Hello world!*"
local newString = string.gsub(newString, "**", "<b>", 1)
local newString = string.gsub(newString, "**", "</b>", 1)
print(newString)
--output <b>Hello world!</b>

You should have mentioned you needed it for cases where there are more than 1 pair of bold tags.

Yeah I tried deleting it, but it seems like it wouldn’t wanna delete.

It would be easy to do it on only one pair, but its complicated on more

local newString = "**Hello world!**LOL**Hello world!**LOL**Hello world!**"
local count = 0

for match in string.gmatch(newString, "%*%*") do
	if count % 2 == 0 then
		newString = string.gsub(newString, "%*%*", "<b>", 1)
	else
		newString = string.gsub(newString, "%*%*", "</b>", 1)
	end
	count += 1
end

print(newString)

image

Okay thank you!! That works!!!