Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to use Regular Expression to find SSN and then replace

$
0
0

I found a regular expression in a pattern I think I need for Social Security Number.

(?!000)(?!666)^([0-8]\d{2})(\d{2})(\d{4})$

My files do not have spaces within the numbers or hyphens.

I want to find all SSN in all. txt document in a specific folder and then replace them with X except for the last 4 digits on right.  It would be nice to tell the user how many were found and replaced.  (That might be a bit much to ask I know.)

My folder path is here \\shared\e_drive\Process\Scrub.

Can someone point me in the right direction 1)Excecute this expression and find social sec numbers 2)Replace those matches with all XXXX except last 4 numbers. 3) Message of completion.   Thanks for any help.

I found a couple similar examples via google but not really the same.




Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>