FinalVersion Posted October 23, 2009 Posted October 23, 2009 I've read the documentation and it didn't really help me that much. Any basically say if I have.. fistname:joe lastname:smith firstname:john lastname:howard I know how to get the information from a textfile, the hard part it splitting it up. Basically I'd like it in an array ( if possible ) like $name[1] would containt joe smith and $name[2] would contain john howard, anyway thanks. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
water Posted October 23, 2009 Posted October 23, 2009 (edited) You need something like: #include <Array.au3> #include <File.au3> Global $asInFile Global $asOutArray[1] = [0] Global $iOutCount = 0 _FileReadToArray("C:\temp\test.txt",$asInFile) For $i = 1 To $asInFile[0] $asSplit = StringSplit($asInFile[$i],":") If @error <> 1 Then If $asSplit[1] = "firstname" Then ReDim $asOutArray[UBound($asOutArray)+1] $iOutCount = $iOutCount + 1 $asOutArray[$iOutCount] = $asSplit[2] EndIf If $asSplit[1] = "lastname" Then $asOutArray[$iOutCount] = $asOutArray[$iOutCount] & " " & $asSplit[2] EndIf EndIf Next $asOutArray[0] = UBound($asOutArray)-1 _ArrayDisplay($asOutArray) Edited October 23, 2009 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
FinalVersion Posted October 23, 2009 Author Posted October 23, 2009 Thanks, but what if i got the text via _IEBodyReadText, how would I convert that into the array to start the string manipulation. Sorry, should of put this in my first post. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
Authenticity Posted October 23, 2009 Posted October 23, 2009 You need to show a sample of the format because otherwise it can be in any form such as lastname comes before firstname or there is something between them and what not. #include <Array.au3> Local $avMatch Local $sText = "firstname:joe" & @CRLF & _ "lastname:smith" & @CRLF & @CRLF & _ "firstname:john" & @CRLF & _ "lastname:howard" $avMatch = StringRegExp($sText, "(?i)firstname:([^\r\n]*)\r\nlastname:([^\r\n]*)", 3) If IsArray($avMatch) Then Local $avNames[UBound($avMatch)/2][2] For $i = 0 To (UBound($avMatch)/2) Step 2 $avNames[$i/2][0] = $avMatch[$i] $avNames[$i/2][1] = $avMatch[$i+1] Next _ArrayDisplay($avNames) EndIf
FinalVersion Posted October 23, 2009 Author Posted October 23, 2009 Ok. Couple paragraphs or so of text up here. And some more, down here. firstname:joe lastname:smith firstname:jack lastname:johnson and the list goes on. I'm getting this from _IEBodyReadText if you didn't know. [center][+] Steam GUI [+][+] Clipboard Tool [+][+] System :: Uptime [+][+] StarCraft II Mouse Trap [+][/center]
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