Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-05-2021, 11:41 AM
lalywizz lalywizz is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Novice
Find/replace - remove a space in 4 digit numbers
 
Join Date: Sep 2021
Posts: 7
lalywizz is on a distinguished road
Default Find/replace - remove a space in 4 digit numbers

Hi there. In my text, I would like to remove the space for every 4 digits numbers (ex. 2 000 becomes 2000). However, I also have numbers of 1 000 000 or more in this text which thousands are separated by spaces. And by removing the spaces for every 4 digits numbers, I don't want it to affect the numbers of 1 000 000 or more (i.e. I don't want the number "1 000 000" to become "1000 000" because of this change).



I'm looking for a way to do a find/replace (using wildcards) so that 4 digit numbers don't contain a space, but for numbers 1 000 000 and above, the space remains present.

Any suggestion? Thanks.

Last edited by lalywizz; 10-06-2021 at 06:28 AM.
Reply With Quote
  #2  
Old 10-06-2021, 08:16 AM
lalywizz lalywizz is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Novice
Find/replace - remove a space in 4 digit numbers
 
Join Date: Sep 2021
Posts: 7
lalywizz is on a distinguished road
Default

Ok, nevermind, I found the solution myself.

For those interested, once I remove space for all 4 digit numbers, the numbers of 1 000 000 or more look like this: 1000 000. Then I did a Find/replace using wildcards. I did enter:

([0-9]{1})([0-9]{3}) ([0-9]{3})

Note there is a space before the last sequence.

In the Replace with: I did enter

\1 \2 \3

So 1000 000 becomes 1 000 000. Exactly what I was looking for.

Cheers.
Reply With Quote
  #3  
Old 10-06-2021, 04:00 PM
macropod's Avatar
macropod macropod is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

A single wildcard Find/Replace would suffice:
Find = ([!0-9]?[0-9]@) ([0-9]{3}?[!0-9])
Replace = \1\2
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 10-07-2021, 06:17 AM
lalywizz lalywizz is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Novice
Find/replace - remove a space in 4 digit numbers
 
Join Date: Sep 2021
Posts: 7
lalywizz is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
A single wildcard Find/Replace would suffice:
Find = ([!0-9]?[0-9]@) ([0-9]{3}?[!0-9])
Replace = \1\2

This one doesn't work... I got 0 result.
Reply With Quote
  #5  
Old 10-07-2021, 03:56 PM
macropod's Avatar
macropod macropod is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Works for me. With text like:
Quote:
numbers of 1 000 000 or more and numbers of 1 000 or more
the result is:
Quote:
numbers of 1 000 000 or more the numbers of 1000 or more
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 10-08-2021, 09:27 AM
lalywizz lalywizz is offline Find/replace - remove a space in 4 digit numbers Windows 10 Find/replace - remove a space in 4 digit numbers Office 2016
Novice
Find/replace - remove a space in 4 digit numbers
 
Join Date: Sep 2021
Posts: 7
lalywizz is on a distinguished road
Default

You're right! It's working! I probably included a space when I did copy/paste the first time.

Good work! Thanks!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Find and Replace and add colon and space falcios Word 2 07-28-2021 04:38 AM
Find/replace - remove a space in 4 digit numbers Using find and replace to insert an extra space after full stops Johanna Word 33 03-07-2020 01:43 PM
Macro for Find/replace to remove space before Hard Return AlfredStreich Word VBA 4 01-23-2020 03:59 PM
Find/replace - remove a space in 4 digit numbers Find and Replace with space cheech1981 Word 3 03-29-2017 02:33 PM
Find/replace - remove a space in 4 digit numbers remove color from find/replace? Cobb78 Word 1 05-26-2012 06:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:22 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft