Regular Expressions - Partial Mask

whhaatt

Registered User.
Local time
, 17:02
Joined
Aug 10, 2005
Messages
42
I am trying to do a find and replace in msword

problem:

I need to search for the following format

REF NO: 84542654
REF NO: 21364589

i need to replace the first 4 digits in the number with * so the iuput should be

REF NO: ****2654
REF NO: ****4589

I cannot seem to get this working

I have tried the following

Find - REF NO: \[0-9]
Replace - ****

I cannot figure out how to specify to only replace the first 4 digits.

I am happy to use VBA code via a module as an option
 
Remember the regex will replace the entire string it matches

So the find will be something like:

REF NO [0-9][0-9][0-9][0-9]

this will return a match of REF NO 1234 against say REF NO 123456789

then replace this match with

REF NO ****
 
Excellent that worked
:)

Thanks for that
 

Users who are viewing this thread

Back
Top Bottom