Comment by [deleted] on 27/01/2021 at 23:03 UTC

1 upvotes, 1 direct replies (showing 1)

View submission: Reintroducing the /r/AutoModerator wiki!

Did you source the UK part of the phone number regex from somewhere? It fails to match a single UK geographic number.

https://en.wikipedia.org/wiki/Telephone_numbers_in_the_United_Kingdom#Format

Replies

Comment by dequeued at 27/01/2021 at 23:33 UTC*

3 upvotes, 1 direct replies

The UK part is unfortunately better suited for warning people to verify phone numbers rather than alerting on doxing. I adapted it from a regex I'm using on /r/personalfinance for that purpose. I'll try to add a caveat of some sort.

If you need a broader regex, I'd probably start with the Ofcom documentation rather than Wikipedia:

https://www.ofcom.org.uk/__data/assets/pdf_file/0013/102613/national-numbering-plan.pdf

Of course, if you are just trying to match numbers for a specific region or city, that's a **much** easier problem.

Edit: I improved the regex and tested it out on some data from UK subreddits. I think it will catch *most* regional numbers provided that the number starts with the 01 or 02 prefix. If you need to go after local numbers that lack one of the supported prefixes then I'd recommend adding a custom regex.