Jump to content

String.Find


#Paper

Recommended Posts

explain it better as i dont understand it..

you cant to count character instances in string?

like on every vote you are adding "+" to string, then you have like "+++++++" and want to count it? this is the way i understood it.

For example:

In a txt file I have the string with "hello" how can I do to have as many are there these strings?

Link to comment

uhm, this is a bit weird way, but the simpliest i think

  
function countWord(text, word) 
  local changed, count = string.gsub(text, word, function() end) 
  return count 
end 
  

it will work only with simple words like : "hello".

it will fail if use with chars like

  
[ ] ( ) . * { } % 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...