Damein Posted February 17, 2016 Share Posted February 17, 2016 (edited) Hello guys, I'm trying to find the best way to parse a list of things and I think a StringReg would be best but I have still yet to really learn them. So my goal here is to get some help with this and than once I get the script working to dwell into why the StringReg did what it did ect. since its something I will have actual knowledge of why it worked lol If this is not a StringReg problem and I can do it another means than so be it I just can't think of how to do it. Thanks! I'll be having a variable list that any of the items can change by the format will remain the same. toilet paper (Household) - Need pens (Office) - Have trashbags (Household) - Have So the format will stay XItem (XLocation) - XState I'll be creating a For statement to pull each of the XItem and XState I want to be able to pull the XItem and XState into a var and manipulate it into a text document. The XLocation isn't important. If I didn't explain well enough please let me know, thanks! Edited February 17, 2016 by Damein Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
jguinch Posted February 17, 2016 Share Posted February 17, 2016 Not sure to understand .... #Include <Array.au3> Local $aItems = [ "toilet paper (Household) - Need", "pens (Office) - Have", "trashbags (Household) - Have"] For $i = 0 To UBound($aItems) - 1 $aRes = StringRegExp($aItems[$i], "^(.+)\h+\([^)]+\)\h+-\h+(.+)", 1) _ArrayDisplay($aRes) Next Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
iamtheky Posted February 17, 2016 Share Posted February 17, 2016 I decided to practice parsing and organizing while on this thread, OT a bit but in case it is useful #Include <Array.au3> Local $aItems = [ "toilet paper (Household) - Need", "pens (Office) - Have", "trashbags (Household) - Have"] Local $aFinal = 0 For $i = 0 To UBound($aItems) - 1 $aRes = StringRegExp($aItems[$i], "(.+)(\(.*\))\s-\s(.*\z)", 3) _ArrayTranspose($aRes) If $aFinal = 0 Then local $aFinal[0][ubound($aRes , 2)] _ArrayAdd($aFinal , $aRes) Next _ArrayDisplay($aFinal) ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
Damein Posted February 17, 2016 Author Share Posted February 17, 2016 (edited) Alright, these are good to start off with and hey work if I have the list hard coded into an array but what if the list isn't hard coded? I suppose the best way would be to do something like a... $Clip = ClipGet() And then split the clip into lines? But without a common delimiter I'm not sure the most practical way of doing this. Assuming this is the list we copy, just as is, what do you think the best way to go about it, also assume that "Need" and "Have" are not always what follows the - toilet paper (Household) - Need pens (Office) - Have trashbags (Household) - Have Edited February 17, 2016 by Damein Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic Link to comment Share on other sites More sharing options...
Damein Posted February 17, 2016 Author Share Posted February 17, 2016 Ah, using StringSplit($Clip, @CR) works just fine. I'll post a finished code for this section when I'm done if someone doesn't before me. Most recent sig. I made Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic 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