AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Cant get rid of Clipboard Spaces

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Deo85



Joined: 21 Dec 2009
Posts: 2

PostPosted: Sat Feb 27, 2010 2:21 am    Post subject: Cant get rid of Clipboard Spaces Reply with quote

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.
Back to top
View user's profile Send private message
entropic



Joined: 21 Dec 2008
Posts: 181

PostPosted: Sat Feb 27, 2010 2:46 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
sinkfaze



Joined: 18 Mar 2008
Posts: 5044
Location: the tunnel(?=light)

PostPosted: Sat Feb 27, 2010 5:06 am    Post subject: Reply with quote

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

_________________
Try Quick Search for Autohotkey or see the tutorial for newbies.
Back to top
View user's profile Send private message Send e-mail
da_boogie_man
Guest





PostPosted: Sat Feb 27, 2010 6:15 pm    Post subject: Reply with quote

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
Back to top
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group