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 

RegEx Question

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



Joined: 26 Nov 2008
Posts: 32

PostPosted: Sun Jan 17, 2010 7:27 pm    Post subject: RegEx Question Reply with quote

How to seperate and display "224Way Street" as "224 Way Street"?

What i've done only managed to find where 4W touch.

Code:

#SingleInstance
fileselectfile, csvfile
fileread,csv,%csvfile%
loop,parse,csv,`r,`n
   Loop,Parse,A_LoopField,CSV
if A_loopfield contains %address%
{
RegExMatch(A_Loopfield, "\d\D", address, 1)
NewAddress := RegExReplace(address, "\d\D", address, 0, -1, 1)
msgbox, %A_Loopfield% %newaddress%
}

Back to top
View user's profile Send private message
tic



Joined: 22 Apr 2007
Posts: 1786

PostPosted: Sun Jan 17, 2010 7:36 pm    Post subject: Reply with quote

Code:
Addr = 224Way Street
NewAddr := RegExReplace(Addr, "(\d+)(\s*)(.+)", "$1 $3")
MsgBox, %NewAddr%
Back to top
View user's profile Send private message
bqw371



Joined: 26 Nov 2008
Posts: 32

PostPosted: Sun Jan 17, 2010 7:57 pm    Post subject: Reply with quote

tic,

Thanks works great. How would I most easily replace the incorrect data with this correct data in .csv?

Lname,Fname,info1,info2,address,etc,etc
smith,john,(null),(null),204Way Ln., etc,etc,
Back to top
View user's profile Send private message
bqw371



Joined: 26 Nov 2008
Posts: 32

PostPosted: Sun Jan 17, 2010 8:04 pm    Post subject: Reply with quote

So now that "224WayRoad" has become "224 WayRoad" I need to know how to put a space before any Capitalized letter, if there is not already a space in front of said cap letter so that I'm left with ""224 Way Road"


Code:
#SingleInstance
fileselectfile, csvfile
fileread,csv,%csvfile%
loop,parse,csv,`r,`n
   Loop,Parse,A_LoopField,CSV
   {
Addr = %A_LoopField%
RegExMatch(A_Loopfield, "\d\D", nospace, 1)   
if A_loopfield contains %nospace%
{
Addr = %A_LoopField%
NewAddr := RegExReplace(Addr, "(\d+)(\s*)(.+)", "$1 $3")
;MsgBox, Old Address: %Addr%`rNew Address: %NewAddr%
FileAppend, %NewAddr%`r`n, addy.txt
}
else
FileAppend, %Addr%`r`n, addy.txt
}
Back to top
View user's profile Send private message
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Sun Jan 17, 2010 9:06 pm    Post subject: Reply with quote

Code:
NewAddr := RegExReplace(NewAddr, "(\S)([A-Z])", "$1 $2")

(untested)
_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"

Antonio França
My stuff: Google Profile
Back to top
View user's profile Send private message Visit poster's website
bqw371



Joined: 26 Nov 2008
Posts: 32

PostPosted: Mon Jan 18, 2010 4:25 am    Post subject: Reply with quote

Thanks! This works very well!
Back to top
View user's profile Send private message
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