-5

I need a RegEx expression to avoid spam with symbols. I give you an example that I want to avoid with RegEx:

The normal IP:

5.196.39.29

The IP that I want to censore:

5.--.196.--.39.--.29
5  -  196  - 39  - 29

and all other combinations..

How can I do that?

2 Answers2

1

It sounds like what you want is "5, some non-digits, 196, some non-digits, 39, some non-digits, 29"

That looks like this:

/5\D+196\D+39\D+29/
Andy Lester
  • 91,102
  • 13
  • 100
  • 152
0

This is what you are looking for:

5[\s.-]*196[\s.-]*39[\s.-]*29

Will detect all the following cases:

5.196.39.29
5.--.196.--.39.--.29
5  -  196  - 39  - 29

You can check it here: https://www.regex101.com/r/kP9mI2/1

Paco Abato
  • 3,920
  • 4
  • 31
  • 54