Jump to content
Sign in to follow this  
DirtDBaK

How do i find the number of occurance of one string in a txt file

Recommended Posts

DirtDBaK

How do i find the number of occurance of one string in a txt file

like this

I am really really fat... and you are really really whatever...

and this would return the rusult for 'really' as 4 or the result of '.' as 6

I was thinking

$num_of_occ = _StringOcc(  'I am really really fat... and you are really really whatever...', 'really' )
  
  
  Func _StringOcc( $txt, $string )
  $i = 1
  $val = StringinStr( $txt, $string, 0, $i )
  While $val <> 0
  $i = $i + 1
  $val = StringinStr( $txt, $string, 0, $i )
  Wend
  Return $val
  EndFunc

[center][/center]

Share this post


Link to post
Share on other sites
SmOke_N

Func _StrOccur($sString, $sFind)
    StringReplace($sString, $sFind, "")
    Return @extended
EndFunc


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
DirtDBaK

ok thanks ill try this out


[center][/center]

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×