regex

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatePattern           = `` /* 461-byte string literal not displayed */
	TimePattern           = `(?i)\d{1,2}:\d{2} ?(?:[ap]\.?m\.?)?|\d[ap]\.?m\.?`
	PhonePattern          = `` /* 133-byte string literal not displayed */
	PhonesWithExtsPattern = `` /* 273-byte string literal not displayed */
	LinkPattern           = `` /* 176-byte string literal not displayed */
	EmailPattern          = `(?i)([A-Za-z0-9!#$%&'*+\/=?^_{|.}~-]+@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)`
	IPv4Pattern           = `(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)`
	IPv6Pattern           = `` /* 1224-byte string literal not displayed */
	IPPattern             = IPv4Pattern + `|` + IPv6Pattern
	NotKnownPortPattern   = `6[0-5]{2}[0-3][0-5]|[1-5][\d]{4}|[2-9][\d]{3}|1[1-9][\d]{2}|10[3-9][\d]|102[4-9]`
	PricePattern          = `[$]\s?[+-]?[0-9]{1,3}(?:(?:,?[0-9]{3}))*(?:\.[0-9]{1,2})?`
	HexColorPattern       = `(?:#?([0-9a-fA-F]{6}|[0-9a-fA-F]{3}))`
	CreditCardPattern     = `(?:(?:(?:\d{4}[- ]?){3}\d{4}|\d{15,16}))`
	VISACreditCardPattern = `4\d{3}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}`
	MCCreditCardPattern   = `5[1-5]\d{2}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}`
	BtcAddressPattern     = `[13][a-km-zA-HJ-NP-Z1-9]{25,34}`
	StreetAddressPattern  = `` /* 149-byte string literal not displayed */
	ZipCodePattern        = `\b\d{5}(?:[-\s]\d{4})?\b`
	PoBoxPattern          = `(?i)P\.? ?O\.? Box \d+`
	SSNPattern            = `(?:\d{3}-\d{2}-\d{4})`
	MD5HexPattern         = `[0-9a-fA-F]{32}`
	SHA1HexPattern        = `[0-9a-fA-F]{40}`
	SHA256HexPattern      = `[0-9a-fA-F]{64}`
	GUIDPattern           = `[0-9a-fA-F]{8}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{4}-?[a-fA-F0-9]{12}`
	ISBN13Pattern         = `(?:[\d]-?){12}[\dxX]`
	ISBN10Pattern         = `(?:[\d]-?){9}[\dxX]`
	MACAddressPattern     = `(([a-fA-F0-9]{2}[:-]){5}([a-fA-F0-9]{2}))`
	IBANPattern           = `[A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}([A-Z\d]?){0,16}`
	GitRepoPattern        = `((git|ssh|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:/\-~]+)(\.git)(\/)?`
)

Regular expression patterns

Variables

Compiled regular expressions

Functions

func BtcAddresses

func BtcAddresses(text string) []string

BtcAddresses finds all bitcoin addresses

func CheckParam

func CheckParam(params ...string) bool

检测参数

func CreditCards

func CreditCards(text string) []string

CreditCards finds all credit card numbers

func Date

func Date(text string) []string

Date finds all date strings

func Emails

func Emails(text string) []string

Emails finds all email strings

func GUIDs

func GUIDs(text string) []string

GUIDs finds all GUID strings

func GitRepos

func GitRepos(text string) []string

GitRepos finds all git repository addresses which have protocol prefix

func HexColors

func HexColors(text string) []string

HexColors finds all hex color values

func IBANs

func IBANs(text string) []string

IBANs finds all IBAN strings

func IPs

func IPs(text string) []string

IPs finds all IP addresses (both IPv4 and IPv6)

func IPv4s

func IPv4s(text string) []string

IPv4s finds all IPv4 addresses

func IPv6s

func IPv6s(text string) []string

IPv6s finds all IPv6 addresses

func ISBN10s

func ISBN10s(text string) []string

ISBN10s finds all ISBN10 strings

func ISBN13s

func ISBN13s(text string) []string

ISBN13s finds all ISBN13 strings

func IsIdCard

func IsIdCard(cardNo string) bool

判断是否是18或15位身份证

func IsMail

func IsMail(username string) (isMail bool)

判断用户是否是邮件用户

func IsPhone

func IsPhone(mobileNum string) bool

判断是否是手机号

func IsRunTesting

func IsRunTesting() bool

判断是否在测试环境下使用

func IsValidPort

func IsValidPort(port int) bool

0 is considered as a non valid port

func IsValidateEmail

func IsValidateEmail(email string) (err error)

验证是否是合法的邮箱

func IsValidateUsername

func IsValidateUsername(username string) error

验证用户名合法性,用户名必须由5-12位(数字、字母、_、-)组成,且必须以字母开头。

func Links(text string) []string

Links finds all link strings

func MACAddresses

func MACAddresses(text string) []string

MACAddresses finds all MAC addresses

func MCCreditCards

func MCCreditCards(text string) []string

MCCreditCards finds all MasterCard credit card numbers

func MD5Hexes

func MD5Hexes(text string) []string

MD5Hexes finds all MD5 hex strings

func NotKnownPorts

func NotKnownPorts(text string) []string

NotKnownPorts finds all not-known port numbers

func Phones

func Phones(text string) []string

Phones finds all phone numbers

func PhonesWithExts

func PhonesWithExts(text string) []string

PhonesWithExts finds all phone numbers with ext

func PoBoxes

func PoBoxes(text string) []string

PoBoxes finds all po-box strings

func Prices

func Prices(text string) []string

Prices finds all price strings

func RegexpReplace

func RegexpReplace(reg, src, temp string) string

RegexpReplace ...

func SHA1Hexes

func SHA1Hexes(text string) []string

SHA1Hexes finds all SHA1 hex strings

func SHA256Hexes

func SHA256Hexes(text string) []string

SHA256Hexes finds all SHA256 hex strings

func SSNs

func SSNs(text string) []string

SSNs finds all SSN strings

func StreetAddresses

func StreetAddresses(text string) []string

StreetAddresses finds all street addresses

func Time

func Time(text string) []string

Time finds all time strings

func VISACreditCards

func VISACreditCards(text string) []string

VISACreditCards finds all VISA credit card numbers

func ZipCodes

func ZipCodes(text string) []string

ZipCodes finds all zip codes

Types

This section is empty.

Jump to

Keyboard shortcuts

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