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

How can I remove part of a string?

Asked by 10 years ago

For example:

local StringToAction = "TESTING <script></script>" -- Using httpservice as an example

- I would like to remove the <script> and </script> tags whilst also removing their inner content.

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

Using this:

local StringToAction = "Testing <script></script>"

local start, temp1 = StringToAction:find("<script>")
local temp2, endS = StringToAction:find("</script>", temp1)

local CleansedString = StringToAction:sub(1, start - 1) .. "" .. StringToAction:sub(endS + 1, StringToAction:len())
1
The code provided seems to only remove "Testing" instead of the HTML. RaverKiller 668 — 10y
0
Woops, sorry, forgot a 1. Let me edit the post. adark 5487 — 10y
0
Try it now. adark 5487 — 10y
1
It works now, thanks. [Please edit "end" inside your answer to be "endd" or something else in-case an amateur doesn't find that error.] RaverKiller 668 — 10y
0
Haha, didn't even notice that meself, thanks. adark 5487 — 10y
Ad

Answer this question