Quantcast
Channel: CodeProject Latest postings for Regular Expressions
Viewing all articles
Browse latest Browse all 224

Exclude already masked data in regex

$
0
0
hi

I am trying to mask 3 to 8 digit numbers alone exclusively, by excluding already masked data with another regex pattern.
For example it should not match the masked patterns like
[xX\-\*\d{1,4}] , but match the pattern \d{3,8}

Can you please help with the regex pattern to achieve this?
I have tried something like this, but its not matching for the pattern \d{3,8}

(?<=(?<!x\-\*)\d{4})\d{3,8}


Input :

1234
x123412345678
-123412345678
*123412345678
123
1234
12345
123456
1234567
12345678

Expected masking

****
x1234****
-1234****
*1234****
****
****
****
****
****
****

Viewing all articles
Browse latest Browse all 224

Trending Articles



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