String.count: Difference between revisions
Jump to navigation
Jump to search
Krischkros (talk | contribs) No edit summary |
m (dont mix languages) |
||
Line 1: | Line 1: | ||
This Function counts a text from a text. | This Function counts a text from a text. | ||
It is server side and client side! | It is server side and client side! | ||
Line 22: | Line 20: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
outputChatbox(string.count("A Text", "T")) -- and the result is 2! | outputChatbox(string.count("A Text", "T")) -- and the result is 2! | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Code and Edit by Krischkros. | Code and Edit by Krischkros. |
Revision as of 23:56, 24 July 2012
This Function counts a text from a text. It is server side and client side!
function string.count(text, search) if search and text then local string_count = 0 for i in string.gfind(text, search) do string_count = string_count + 1 end return string_count else return 0 end end
Usage:
outputChatbox(string.count("A Text", "T")) -- and the result is 2!
Code and Edit by Krischkros.