Reputation: 2170
Someone is spamming my site with fake telephone numbers, I want to filter all telephone numbers on my site. The numbers are in format :
0862123652
So ten numbers where the first one is always 0, but spammers also use :
08 62 1 2 3 ///6 \\\52
08 62 1 .....2 *** 3+++ ///6 \\\52
So I cannot filter these ones with parttern like 0[0-9]{9}
. How could I do this?
Thanks.
Upvotes: 1
Views: 92
Reputation: 6511
Check if the string has exactly 10 digits (starting with 0
):
^\D*0\D*(?:\d\D*){9}$
If you need to narrow it down, you could change every \D
with the specific set of symbols that may occur between digits. For example:
^[.*+/\\ ]*0[.*+/\\ ]*(?:\d[.*+/\\ ]*){9}$
I'm positive you could create these kind of expressions if you read a couple of minutes about regex syntax, so allow me to recommend:
Upvotes: 2