String.count
Jump to navigation
Jump to search
This function counts how many times a string is found from within another string.
Syntax
int string.count(string text, string search)
Required Arguments
- text: A string to find the text from
- search: A string defining what to find
Code
function string.count (text, search) if ( not text or not search ) then return false end return select ( 2, text:gsub ( search, "" ) ); end
Usage:
outputChatBox( string.count( "Just a test string", "t" ) ) -- and the result is 4!
Created by Krischkros, Edited by nextz.