tempman Posted March 19, 2013 Posted March 19, 2013 (edited) This is my input: 1.0.0.0,1.0.0.255,Australiaand this is how my output in test.txt with leading zeros should look like: 001.000.000.000,001.000.000.255,Australia#include <Array.au3> $text = '1.0.0.0,1.0.0.255,Australia' $atext = StringSplit($text, ",") $file = FileOpen("test.txt", 2) For $i = 1 To 2 $array = StringRegExp($atext[$i], '(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})', 3) For $j = 0 To 3 $k = StringFormat("%03i",$array[$j]) MsgBox(4096, "output", $k) Next Next FileClose($file)Where to put and how to use FileWriteLine function? Edited March 19, 2013 by tempman
water Posted March 19, 2013 Posted March 19, 2013 (edited) Something like this: #include <Array.au3> $text = '1.0.0.0,1.0.0.255,Australia' $atext = StringSplit($text, ",") $file = FileOpen("test.txt", 2) For $i = 1 To 2 $array = StringRegExp($atext[$i], '(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})', 3) For $j = 0 To 3 $k = StringFormat("%03i", $array[$j]) MsgBox(4096, "output", $k) FileWrite($file, $k) If $j < 3 Then FileWrite($file, ".") Else FileWrite($file, ",") EndIf Next Next FileWriteLine($file, $atext[3]) FileClose($file) Exit Edited March 19, 2013 by water 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
water Posted March 19, 2013 Posted March 19, 2013 BTW: Could you please set a meaningful title for your threads? People should know if it is worth opening the thread! 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
tempman Posted March 19, 2013 Author Posted March 19, 2013 (edited) @water If $j < 3 Then FileWrite($file, ".") Else FileWrite($file, ",") EndIf I'll never thought of that , thank you! BTW: Could you please set a meaningful title for your threads? People should know if it is worth opening the thread! Honestly, I didn't know how to call a topic. Edited March 19, 2013 by tempman
PhoenixXL Posted March 19, 2013 Posted March 19, 2013 (edited) This way$text = '1.0.0.0,1.0.0.255,Australia' Do $text = StringRegExpReplace($text, '(^|\D)(\d{1,2})($|\D)', '${1}0\2\3' ) Until Not @extended MsgBox(64, "Info", $text ) Edited March 19, 2013 by PhoenixXL My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.
water Posted March 19, 2013 Posted March 19, 2013 Honestly, I didn't know how to call a topic.Something like: "Format IP address and write to file" 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
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