Looking for ideas to mask part of a creditcard

Trying to mask out a part (6-10th digit) of the 16 digit credit card.

1234567898763456 to 1234######3456

I can think of using gsub filter, but I can't find a way to match the exact section of numbers.

The option would be to split in various sections and then gsub the whole field to '#' and then join back, seems too much work. Any suggestions.

Something like this will mask the whole thing, which i don't want.

filter
{
  mutate {
    gsub => [
      "message","[0-9]{16}","################"   
    ]
  }
}

@Saurav_Sen, using regex capture groups along the lines of the example below should work for you:

filter
{
  mutate {
    gsub => [
      "message","([0-9]{5})([0-9]{5})([0-9]{6})", "\1#####\3"
    ]
  }
}
1 Like

Thanks a lot @danhermann, i tweaked it a bit to get the combination I wanted.works great

eg:
9999999999999999 to 999999######9999

filter {
    mutate {
    gsub => [
      "message","([0-9]{6})([0-9]{6})([0-9]{4})", "\1######\3"
    ]
  }
}

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.