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

Help With String Manipulation?

Asked by
MixCorp 70
10 years ago

Alright, When you do string.find You can find a certain string inside of a string

a = " A B C D E F G "
if a:find("A") then
print("It has an a in it :O")
end

But when I try this, It doesn't return true or false, It returns numbers. What do they mean? xD Here is an example:

b = "Testing 1234"
print(b:find(3))
--It then returns 11 11

--

c = "Hello World!"
print(c:find("Wor"))
--Returns 7 9

What are the numbers?

0
Example one looked like it would be just string position. But, Example 2 is 7 and 9 which isnt where the string is. MixCorp 70 — 10y

1 answer

Log in to vote
0
Answered by
duckwit 1404 Moderation Voter
10 years ago

The range of indices of the string, notice that in your "Testing 1234" example, the string "3" goes from the 11th character to the 11th character. In the "Hello World!" example, "Wor" goes from the 7th to the 9th character.

0
Lol this entire post was about me miss counting characters in Hello World xD MixCorp 70 — 10y
Ad

Answer this question