AutoHotkey Community

It is currently May 27th, 2012, 4:30 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: February 27th, 2010, 3:21 am 
Offline

Joined: December 21st, 2009, 9:29 pm
Posts: 2
Hey all I been trying to find the answer to this question over and over again with no luck so I decided to finally submit a request for help. I am trying to parse out data that is copied to the clipboard from a link we get called "NEC"

I figured I replace all the common terms with $-$ then make a StringPlit from there to get to the data I wanted BUT I am having trouble all ready as I cant remove blank spaces from my variable.

Here is a parts of what it looks like from my variable its rather large so I wont post it all here:

Employ Checklist System:


$-$

REQ990342 New Mar 1 2010 12:00 AM 2/9/2010 2:25:59 PM Laptop


$-$

Now I need to Extract "Laptop" from that but some times it may say either "Desktop" or "WYSE" If I could get rid of the black spaces so it said

$-$
REQ990342 New Mar 1 2010 12:00 AM 2/0/2010 2:25:59 PM Laptop
$-$

I should be able to pull that array to a variable then subdivide that variable into another Array and grab the 11 slot and get "Laptop"

StringSplit, NECMachine, NECDATA3, %A_Space%
and "Laptop" would be %NECMachine11% if my calculations are correct.


So I know that was a bit long but I figured show you guys were I am going with this so if you can help THANKS! I will keep researching and trying to find a answer to this problem.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 3:46 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
Does this do what you're looking for?
Code:
str =
(


REQ990342 New Mar 1 2010 12:00 AM 2/9/2010 2:25:59 PM Laptop


)

RegExMatch(str, "i)(AM|PM)\s([A-Z]+)", Match)

Msgbox %Match2%


Explanation for the RegEx:
Code:
i)       - Make the matching case insensitive
(AM|PM)  - Match either AM or PM
\s       - Match a space " "
([A-Z]+) - Match one or more characters "+" of the class A-Z, the parenthesis around it tells it to store the part that matches, it's called a capturing subpattern.  Check out the documentation on RegEx for more information.


Also www.gskinner.com/RegExr is a great online tool for testing out regular expressions.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 6:06 am 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5480
Location: the tunnel(?=light)
A slightly shorter way to do it, this will remove any sets of two or more vertical whitespace characters (return,newline,etc.) and replace them with a single return and newline:

Code:
Clipboard=
(
$-$

REQ990342 New Mar 1 2010 12:00 AM 2/9/2010 2:25:59 PM Laptop


$-$
)
MsgBox % RegExReplace(Clipboard,"\v{2,}","`r`n")
return

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 27th, 2010, 7:15 pm 
Or you can try this:

>>TESTED<<
Code:
mySet =
(
$-$

REQ990342 New Mar 1 2010 12:00 AM 2/9/2010 2:25:59 PM Laptop


$-$
)

Loop, Parse, mySet, `n
  If (a_loopfield <> "") AND (a_loopfield <> "$-$")
    StringSplit, NECMachine, a_loopfield, %A_Space%

msgbox, %NECMachine11%


I've never messed with the regex stuff so my solutions tend to be a bit simple.

DBM


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Mickers, rbrtryn and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group