phonenumber

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuRegex = `(^8|7|\+7)((\d{10})|(\s\(\d{3}\)\s\d{3}\s\d{2}\s\d{2}))`
	USRegex = `\(?\d{3}\)?-? *\d{3}-? *-?\d{4}`
	DERegex = `[^\d]((\+49|0049|0)[\s]?1[567]\d{1,2}([ \-/]*\d){7})`
	NLRegex = `(?:(?:\+31|0|0031)[\s-]?\d{1,3}[\s-]?\d{6,7}|06[\s-]?\d{8})`
)

Variables

This section is empty.

Functions

func FindTelTagPhones

func FindTelTagPhones(html string) (string, error)

FindTelTagPhones is the primary function for searching for phone numbers in a webpage. It can search for href tel tags and input type tel tags, combining them and returning results separated by a space as a string for further classification of the phone number.

func MapCountryCodeToRegex

func MapCountryCodeToRegex(countryCodes []string) map[string]string

MapCountryCodeToRegex maps each countryCode to the specific regexp

Types

type PhoneNumberFinder

type PhoneNumberFinder interface {
	FindPhoneNumbers(html string) []string
	FormatAndCreateNumbers(webPageId int, phoneNumbers []string) error
}

PhoneNumberValidator is an implementation of PhoneNumberMatcher for a specific country.

type PhoneNumberValidator

type PhoneNumberValidator struct {
	// contains filtered or unexported fields
}

func NewPhoneNumberValidator

func NewPhoneNumberValidator(regexPattern string, countryCode string) (*PhoneNumberValidator, error)

NewPhoneNumberValidator creates a new instance of PhoneNumberValidator.

func (*PhoneNumberValidator) FindPhoneNumbers

func (c *PhoneNumberValidator) FindPhoneNumbers(html string) []string

func (*PhoneNumberValidator) FormatAndCreateNumbers

func (p *PhoneNumberValidator) FormatAndCreateNumbers(webPageId int, phoneNumbers []string)

FormatAndCreateNumbers Validates phone numbers and returns a list of validated phone numbers with as much information as possible From libphonenumbers Function is not perfect and may sometimes fail

type PhoneProcessor

type PhoneProcessor struct {
	// contains filtered or unexported fields
}

func NewPhoneProcessor

func NewPhoneProcessor() *PhoneProcessor

func (*PhoneProcessor) ProcessPhoneNumbers

func (p *PhoneProcessor) ProcessPhoneNumbers(html string, webPageID int, patterns map[string]string)

ProcessPhoneNumbers processes phone numbers in HTML content using specified patterns for different countries.

func (*PhoneProcessor) SetCountryRegex

func (p *PhoneProcessor) SetCountryRegex(countryCode, regexPattern string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL