Jump to content

StringRegExp maybe?


Damein
 Share

Recommended Posts

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 by Damein

MCR.jpg?t=1286371579

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

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

 

Link to comment
Share on other sites

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

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 by Damein

MCR.jpg?t=1286371579

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

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.

MCR.jpg?t=1286371579

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...