To me it was obvious this wouldn’t work but I don’t know how to set the original pattern, the 15 followed by a replace of 11 literal.
In the last example, it does not know the 15 character limit and found and replaced a few system numbers that are long strings that might have a 4,5 or 6 in it. Like it put X’s in this 00780106260001002000. It is also replacing the correct strings in the standalone numbers but I feel something is missing here.
Could anyone offer a suggestion on this type of replace?
You might start with learning more about regular expressions … Finding or Verifying Credit Card Numbers.
It depends pretty much how those credit card numbers are saved but a simple version could be something like this:
To expand a little on Olaf’s excellent suggestion, I typically prefer to use named match groups to make the methodology more clear when re-reading my own code:
Does it register a word boundary for a sequence of numbers?
He was doing negative lookarounds, but the forum formatting broke the regex by adding spaces in between characters needed for the lookaround definitions.
RegExp Preview, I’ve used since it’s release, well, I have Sapien’s PSStudio and the Productivity pack, which include PowerRegEx, so, I actually spend more time with that one.
And there has been a RegEx addon for the ISE since circa 2014
ISERegex - ISE AddOn to simplify the work with Powershell and regular expression
Did you ever worked with Powershell and regular expressions?Are you learning resistant againts regular expressions as I am?If all this applies to you ( or even if not) , then I have a cool solution for this problem. The ISERegex - ISE Add-On is a simple Addon for the Powershell I
https://gallery.technet.microsoft.com/scriptcenter/ISERegex-ISE-AddOn-to-fb5097e1