#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0

    Regex - Partial Mask


    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
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0
    can anyone help?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2011
    Posts
    3
    Rep Power
    0
    I have been pointed in the direction by somone

    the answer is

    find what - REF NO [0-9][0-9][0-9][0-9]
    Replace with - REF NO ***

  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    s/REF NO: \d{4}/REF NO: ****/g

    Modify to match whatever language you're using.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo