How to determine whether a phone number has been posted?
<p>On one of my sites, I have a problem with too many NEW users not reading the rules and posting their phone numbers in public, which is against the rules.</p>

<p>So to put an end to this, I want to check whether a phone number has been submitted before making the post live.  What is the best and most efficient way to determine whether a phone number appears in a string?</p>

<p>Here's my thought process on this:</p>

<p>1) Phone numbers are at least 10 digits.</p>

<p>2) Sometimes users use <code>(</code>, <code>)</code>, <code>-</code>, and spaces within their phone numbers.</p>

<p>So, to check whether a phone number has been posted, it seems like I would have to get the string of the post, remove all of the characters from <code>2)</code> above, and then search for any occurrence of 10 consecutive digits or more.</p>

<p>Of course, this could be circumvented, but the vast majority of new users aren't trying to circumvent the rules, they are just posting their phone numbers completely oblivious to the rules and I don't know how else to stop them so that I don't have to waste so much time moderating the site.</p>

<p>How would I do the above in PHP?  Or is there a better way?</p>

<p><strong>Edit:</strong>  To clarify, my site already has a "report post" button for users to report offending posts, which is how I moderate the site, but 90% of my of my moderation time is spent having to edit out phone numbers and warn those users not to do it. I want to "preempt" the problem so to speak by catching it before it happens, and warning the user about the rules. Sure, users can circumvent it, but then I'll just ban them since they were specifically warned not to do it, and I can't fathom many users knowingly ignoring the rules just to get banned. So my solution would save me A LOT of time, with minimal drawbacks. I just can't fathom many cases on my site where 10 or more consecutive digits are entered that aren't phone numbers, so I'm not worried about false positives.</p>
