olo Posted May 7, 2013 Share Posted May 7, 2013 Hi Im using the below to count the number of times "o" repeats in my $string "olololololol" etc Now then I get the position of each one of those o's. But how do I store the positions into an array?? Func _StringCount($String, $SubString) return (StringLen($String) - StringLen(StringReplace($String, $SubString, ""))) / StringLen($SubString) EndFunc $String = "olololololololol" $SubString = "o" MsgBox(0,"" , _StringCount($String, $SubString)) Local $i Local $tol = 100 For $i = 1 To 100 Step +1 Local $result = StringInStr($String, $SubString, 0, $i) if $result == 0 Then Exit Else MsgBox(0,"DEMO1", $result) EndIf Next Link to comment Share on other sites More sharing options...
water Posted May 7, 2013 Share Posted May 7, 2013 You need the number of "o" in your string or the position of each "o"? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 7, 2013 Author Share Posted May 7, 2013 You need the number of "o" in your string or the position of each "o"?Well they dont have to be in the same array.So1 array contains the number of o'sanother contains the position of each of those o's Link to comment Share on other sites More sharing options...
water Posted May 7, 2013 Share Posted May 7, 2013 Example script: #include <array.au3> $sString = "olololololol" $sSearch = "o" StringReplace($sString, $sSearch, "") ; @extended is set to the number of replacements Global $aPositions[@extended + 1] = [@extended] Global $iPos For $i = 1 To 99999 $iPos = StringInStr($sString, $sSearch, Default, $i) If $iPos = 0 Then exitloop $aPositions[$i] = $iPos Next _ArrayDisplay($aPositions) exit olo 1 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
olo Posted May 7, 2013 Author Share Posted May 7, 2013 wow thanks that works perfect! Link to comment Share on other sites More sharing options...
water Posted May 7, 2013 Share Posted May 7, 2013 Glad to be of service My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now