• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Help With Find and Replace

Joined
Aug 17, 2008
Messages
2,190 (0.38/day)
Location
Minnesota, USA
System Name TaichiTig
Processor i7 6800K
Motherboard ASRock X99 Taichi
Memory 32GB DDR4 3200
Video Card(s) RTX 4070
Storage SSD + Misc. HDDs in DrivePool
Display(s) BenQ PD3200U, Samsung C32HG70
Case Antec Twelve Hundred
Audio Device(s) Behringer UMC404HD, LSR308, Shure SRH840, AKG K612, Etymotic HF5
Power Supply Corsair 750TX
Mouse Logitech G502
Keyboard Deck Legend Ice Tactile
Software Win10
Real basic question for anyone with experience.

I have a long list of cities and zip codes formatted in the following way:

55472 Abmps
56510 Ada


I need to replace the space between each zip code and its city with a comma, as such:

55472,Abmps
56510,Ada


In the Find and replace dialog, next to find I am using [0-9] [A-Z] to find all instances of a number followed by a space followed by a capital letter. This finds everything I need it to.

But then I intuitively tried, next to replace, using [0-9],[A-Z] and it results in this:

5547[0-9],[A-Z]bmps
5651[0-9],[A-Z]da


How can I tell Notepad++ to leave the zip and city alone while changing the space?
 
Joined
Mar 1, 2010
Messages
3,565 (0.69/day)
Location
By the Channel Tunnel, Kent, England
System Name Benny
Processor Phenom II 1055t @ 3.3GHz; 300x11; 1.380v; NB 2700; HT 2400
Motherboard ASUS Crosshair IV Formula (2002 BIOS)
Cooling Thermalright TRUE 120 Black + 2 Xilence Red Wing PWM 120mm (push/pull) + polycarbonate fan holders
Memory 8GB GeIL Ultra 2133MHZ C9 running at 1600MHz @ 7-7-7-21 1T 1.5v
Video Card(s) MSI Twin Frozr II GTX470 @ Stock w/CPU fan cable-tied on, as one of the GPU fans broke.
Storage 60GB OCZ Agility3 (OS);500GB WDC Grn; 1x1TB WDC Blk (Backup)
Display(s) ASUS PA823Q
Case Silverstone Raven 2 (all cables custom sleeved with velcro mod on side panel...)
Audio Device(s) X-Fi (Onboard) + Harmon Kardon HK6100 amp powering JVC HA-RX700's with Zalman mic
Power Supply Corsair HX650W
Software Win7 Pro x64
Benchmark Scores No benchies so making this space useful! Corsair M90, Logitech G19. Phobya FlexLight LED's (gawjus)
There may be a trick you can try:
does the "space" have an Alt code? Like "enter" key combination is Alt+0013.
If you could tell it to find and replace using the Alt code's, that may work.


EDIT:
Space = Alt+32
Comma = Alt+44
 
Joined
Aug 17, 2008
Messages
2,190 (0.38/day)
Location
Minnesota, USA
System Name TaichiTig
Processor i7 6800K
Motherboard ASRock X99 Taichi
Memory 32GB DDR4 3200
Video Card(s) RTX 4070
Storage SSD + Misc. HDDs in DrivePool
Display(s) BenQ PD3200U, Samsung C32HG70
Case Antec Twelve Hundred
Audio Device(s) Behringer UMC404HD, LSR308, Shure SRH840, AKG K612, Etymotic HF5
Power Supply Corsair 750TX
Mouse Logitech G502
Keyboard Deck Legend Ice Tactile
Software Win10
I can actually just type in a space next to "find" and that will find all the spaces. The problem with that is that some of the city names are more than a single word. For example "St. Paul".
 
Joined
Mar 1, 2010
Messages
3,565 (0.69/day)
Location
By the Channel Tunnel, Kent, England
System Name Benny
Processor Phenom II 1055t @ 3.3GHz; 300x11; 1.380v; NB 2700; HT 2400
Motherboard ASUS Crosshair IV Formula (2002 BIOS)
Cooling Thermalright TRUE 120 Black + 2 Xilence Red Wing PWM 120mm (push/pull) + polycarbonate fan holders
Memory 8GB GeIL Ultra 2133MHZ C9 running at 1600MHz @ 7-7-7-21 1T 1.5v
Video Card(s) MSI Twin Frozr II GTX470 @ Stock w/CPU fan cable-tied on, as one of the GPU fans broke.
Storage 60GB OCZ Agility3 (OS);500GB WDC Grn; 1x1TB WDC Blk (Backup)
Display(s) ASUS PA823Q
Case Silverstone Raven 2 (all cables custom sleeved with velcro mod on side panel...)
Audio Device(s) X-Fi (Onboard) + Harmon Kardon HK6100 amp powering JVC HA-RX700's with Zalman mic
Power Supply Corsair HX650W
Software Win7 Pro x64
Benchmark Scores No benchies so making this space useful! Corsair M90, Logitech G19. Phobya FlexLight LED's (gawjus)
Now that's tricky!
Ok, try this. It's long winded as you'll have to repeat the action 10 times.

Find "0 " and replace with "0," then repeat with other numbers.
"9 " "8 " etc.

EDIT: Unless some of the place names have numbers, it should work. Might have to use the Alt codes still.

2ND EDIT: Just read the OP again, if you find "[0-9] [A-Z]" and replace with "," instead of replacing with "[0-9],[A-Z]", does that do anything different?
 
Last edited:
Joined
Aug 17, 2008
Messages
2,190 (0.38/day)
Location
Minnesota, USA
System Name TaichiTig
Processor i7 6800K
Motherboard ASRock X99 Taichi
Memory 32GB DDR4 3200
Video Card(s) RTX 4070
Storage SSD + Misc. HDDs in DrivePool
Display(s) BenQ PD3200U, Samsung C32HG70
Case Antec Twelve Hundred
Audio Device(s) Behringer UMC404HD, LSR308, Shure SRH840, AKG K612, Etymotic HF5
Power Supply Corsair 750TX
Mouse Logitech G502
Keyboard Deck Legend Ice Tactile
Software Win10
That'll get me through this job just fine. I know there's a basic "proper" way of doing this with regex and hope someone will chime in with it for future reference later, but for now I need to get this done.

Thank you much scaminatrix. :toast:
 
Joined
Mar 1, 2010
Messages
3,565 (0.69/day)
Location
By the Channel Tunnel, Kent, England
System Name Benny
Processor Phenom II 1055t @ 3.3GHz; 300x11; 1.380v; NB 2700; HT 2400
Motherboard ASUS Crosshair IV Formula (2002 BIOS)
Cooling Thermalright TRUE 120 Black + 2 Xilence Red Wing PWM 120mm (push/pull) + polycarbonate fan holders
Memory 8GB GeIL Ultra 2133MHZ C9 running at 1600MHz @ 7-7-7-21 1T 1.5v
Video Card(s) MSI Twin Frozr II GTX470 @ Stock w/CPU fan cable-tied on, as one of the GPU fans broke.
Storage 60GB OCZ Agility3 (OS);500GB WDC Grn; 1x1TB WDC Blk (Backup)
Display(s) ASUS PA823Q
Case Silverstone Raven 2 (all cables custom sleeved with velcro mod on side panel...)
Audio Device(s) X-Fi (Onboard) + Harmon Kardon HK6100 amp powering JVC HA-RX700's with Zalman mic
Power Supply Corsair HX650W
Software Win7 Pro x64
Benchmark Scores No benchies so making this space useful! Corsair M90, Logitech G19. Phobya FlexLight LED's (gawjus)
That's alright mate, which way did you use, the long winded way?
 
Joined
Aug 17, 2008
Messages
2,190 (0.38/day)
Location
Minnesota, USA
System Name TaichiTig
Processor i7 6800K
Motherboard ASRock X99 Taichi
Memory 32GB DDR4 3200
Video Card(s) RTX 4070
Storage SSD + Misc. HDDs in DrivePool
Display(s) BenQ PD3200U, Samsung C32HG70
Case Antec Twelve Hundred
Audio Device(s) Behringer UMC404HD, LSR308, Shure SRH840, AKG K612, Etymotic HF5
Power Supply Corsair 750TX
Mouse Logitech G502
Keyboard Deck Legend Ice Tactile
Software Win10
I did it the "long winded way" although really that only took a minute anyway haha so that was just fine.. If I replace [0-9 [A-Z] with just a comma, the comma ends up replacing not only the space but also the last number of each zip and the first letter of each city.
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,051 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
grab ultraedit and use the regexp search and replace
 
Joined
Aug 17, 2008
Messages
2,190 (0.38/day)
Location
Minnesota, USA
System Name TaichiTig
Processor i7 6800K
Motherboard ASRock X99 Taichi
Memory 32GB DDR4 3200
Video Card(s) RTX 4070
Storage SSD + Misc. HDDs in DrivePool
Display(s) BenQ PD3200U, Samsung C32HG70
Case Antec Twelve Hundred
Audio Device(s) Behringer UMC404HD, LSR308, Shure SRH840, AKG K612, Etymotic HF5
Power Supply Corsair 750TX
Mouse Logitech G502
Keyboard Deck Legend Ice Tactile
Software Win10
Thanks W1zzard, trying that out now.
 
Joined
Aug 17, 2009
Messages
1,585 (0.30/day)
Location
Los Angeles/Orange County CA
System Name Vulcan
Processor i6 6600K
Motherboard GIGABYTE Z170X UD3
Cooling Thermaltake Frio Silent 14
Memory 16GB Corsair Vengeance LPX 16GB (2 x 8GB)
Video Card(s) ASUS Strix GTX 970
Storage Mushkin Enhanced Reactor 1TB SSD
Display(s) QNIX 27 Inch 1440p
Case Fractal Design Define S
Audio Device(s) On Board
Power Supply Cooler Master V750
Software Win 10 64-bit
Real basic question for anyone with experience.

I have a long list of cities and zip codes formatted in the following way:

55472 Abmps
56510 Ada


I need to replace the space between each zip code and its city with a comma, as such:

55472,Abmps
56510,Ada


In the Find and replace dialog, next to find I am using [0-9] [A-Z] to find all instances of a number followed by a space followed by a capital letter. This finds everything I need it to.

But then I intuitively tried, next to replace, using [0-9],[A-Z] and it results in this:

5547[0-9],[A-Z]bmps
5651[0-9],[A-Z]da


How can I tell Notepad++ to leave the zip and city alone while changing the space?

Using perl, if the 2 fields are separated by one or more spaces, then

perl -n -e 's/\s+/,/;print' file > newfile
 
Last edited:

Easy Rhino

Linux Advocate
Staff member
Joined
Nov 13, 2006
Messages
15,449 (2.42/day)
Location
Mid-Atlantic
System Name Desktop
Processor i5 13600KF
Motherboard AsRock B760M Steel Legend Wifi
Cooling Noctua NH-U9S
Memory 4x 16 Gb Gskill S5 DDR5 @6000
Video Card(s) Gigabyte Gaming OC 6750 XT 12GB
Storage WD_BLACK 4TB SN850x
Display(s) Gigabye M32U
Case Corsair Carbide 400C
Audio Device(s) On Board
Power Supply EVGA Supernova 650 P2
Mouse MX Master 3s
Keyboard Logitech G915 Wireless Clicky
Software The Matrix
any decent text editor should make it easy for you to find/replace
 
Top