 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
bqw371
Joined: 26 Nov 2008 Posts: 32
|
Posted: Sun Jan 17, 2010 7:27 pm Post subject: RegEx Question |
|
|
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 |
|
 |
tic
Joined: 22 Apr 2007 Posts: 1786
|
Posted: Sun Jan 17, 2010 7:36 pm Post subject: |
|
|
| Code: | Addr = 224Way Street
NewAddr := RegExReplace(Addr, "(\d+)(\s*)(.+)", "$1 $3")
MsgBox, %NewAddr% |
|
|
| Back to top |
|
 |
bqw371
Joined: 26 Nov 2008 Posts: 32
|
Posted: Sun Jan 17, 2010 7:57 pm Post subject: |
|
|
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 |
|
 |
bqw371
Joined: 26 Nov 2008 Posts: 32
|
Posted: Sun Jan 17, 2010 8:04 pm Post subject: |
|
|
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 |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Sun Jan 17, 2010 9:06 pm Post subject: |
|
|
| 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 |
|
 |
bqw371
Joined: 26 Nov 2008 Posts: 32
|
Posted: Mon Jan 18, 2010 4:25 am Post subject: |
|
|
| Thanks! This works very well! |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|