🍫 A collection of common regular expressions for Go

Overview



CommonRegex

A collection of often used regular expressions for Go




Inspired by CommonRegex

This is a collection of often used regular expressions. It provides these as simple functions for getting the matched strings corresponding to specific patterns.

Installation

go get github.com/mingrammer/commonregex

Usage

import (
    cregex "github.com/mingrammer/commonregex"
)

func main() {
    text := `John, please get that article on www.linkedin.com to me by 5:00PM on Jan 9th 2012. 4:00 would be ideal, actually. If you have any questions, You can reach me at (519)-236-2723x341 or get in touch with my associate at [email protected]`

    dateList := cregex.Date(text)
    // ['Jan 9th 2012']
    timeList := cregex.Time(text)
    // ['5:00PM', '4:00']
    linkList := cregex.Links(text)
    // ['www.linkedin.com', '[email protected]']
    phoneList := cregex.PhonesWithExts(text)  
    // ['(519)-236-2723x341']
    emailList := cregex.Emails(text)
    // ['[email protected]']
}

Features

  • Date
  • Time
  • Phone
  • Phones with exts
  • Link
  • Email
  • IPv4
  • IPv6
  • IP
  • Ports without well-known (not known ports)
  • Price
  • Hex color
  • Credit card
  • VISA credit card
  • MC credit card
  • ISBN 10/13
  • BTC address
  • Street address
  • Zip code
  • Po box
  • SSN
  • MD5
  • SHA1
  • SHA256
  • GUID
  • MAC address
  • IBAN
  • Git Repository

Thanks to ❤️

License

FOSSA Status

Comments
  • In correct Mac regex

    In correct Mac regex

    I was look at the mac regex and found that the regex in your code does not take care of this case: a4:5e:60:d4:03-fb. Where there is mixture of : and - . thanks

    bug 
    opened by Umarhayat3 3
  • change IPv4 regex to ensure last octet was matched

    change IPv4 regex to ensure last octet was matched

    This PR fixes a bug in the IPv4 regex. IP addresses with two or three digits in the last octet were not being matched correctly e.g. 216.58.194.46 was matched as 216.58.194.4

    Summary of changes:

    • Change IPv4 regex to the one from https://www.safaribooksonline.com/library/view/regular-expressions-cookbook/9780596802837/ch07s16.html
    • Add test cases for IPs with two & three digits in the last octet
    opened by jakewarren 2
  • Add license scan report and status

    Add license scan report and status

    Your FOSSA integration was successful! Attached in this PR is a badge and license report to track scan status in your README.

    Below are docs for integrating FOSSA license checks into your CI:

    opened by fossabot 2
  • function name change IPs to IPv4s

    function name change IPs to IPv4s

    I need to distinguish between IPv4 and IPv6. Ip means both of them. How about function IPs return all ips and only function IPv4s return IPv4 address.

    opened by Bill-Park 2
  • refactor/use testify for tests

    refactor/use testify for tests

    Bonjour ! 😄

    I refactored the tests by using testify. It's one of the most used extensions to the go testing package.

    I think that in this case it allows for more clean tests with the use of assert.Equal and assert.NotEqual.

    enhancement 
    opened by fakenine 2
Releases(v1.0.1)
Owner
MinJae Kwon
🐳 Golang & Python. I love computer science, system design, and automate something 💕
MinJae Kwon
Common case conversions covering common initialisms.

kace go get "github.com/codemodus/kace" Package kace provides common case conversion functions which take into consideration common initialisms. Usag

Code Modus 19 Sep 27, 2022
A collection of well-known string hash functions, implemented in Go

This library is a collection of "well-known" 32-bit string hashes, implemented in Go. It includes: Java string hash ELF-32 Jenkins' One-A

Damian Gryski 64 Mar 3, 2022
A tool and library for using structural regular expressions.

Structural Regular Expressions sregx is a package and tool for using structural regular expressions as described by Rob Pike (link).

Zachary Yedidia 40 Sep 21, 2022
A command-line tool and library for generating regular expressions from user-provided test cases

Table of Contents What does this tool do? Do I still need to learn to write regexes then? Current features How to install? 4.1 The command-line tool 4

Peter M. Stahl 5.7k Nov 27, 2022
Compile Go regular expressions to Go code

regexp2go regexp2go is an alternate backend for the regexp package that allows to perform ahead-of-time compilation of regular expressions to Go code.

Carlo Alberto Ferraris 85 Jul 11, 2022
Machine-readable regular expressions for identifying accession numbers for cultural heritage organizations in text.

Machine-readable regular expressions for identifying accession numbers for cultural heritage organizations in text.

San Francisco International Airport Museum 6 Jun 14, 2022
Converts NFAs (and DFAs) to a regular expressions using the state removal method.

nfa-to-regex: convert NFAs (and DFAs) to regular expressions An implementation of the state removal technique for converting an NFA to a regular expre

David Wolever 3 Apr 29, 2022
Converts NFAs (and DFAs) to a regular expressions using the state removal method

nfa2regex: convert NFAs (and DFAs) to regular expressions An implementation of the state removal technique for converting an NFA to a regular expressi

David Wolever 3 Apr 29, 2022
Common case conversions covering common initialisms.

kace go get "github.com/codemodus/kace" Package kace provides common case conversion functions which take into consideration common initialisms. Usag

Code Modus 19 Sep 27, 2022
Turbine-common - This package contains the common interfaces for Turbine that are shared with other software

turbine-common This package contains the common interfaces for Turbine that are

NoraSector 3 Feb 12, 2022
A collection of packages to augment the go testing package and support common patterns.

gotest.tools A collection of packages to augment testing and support common patterns. Usage With Go modules enabled (go1.11+) $ go get gotest.tools/v3

null 370 Nov 28, 2022
A command-line runner for Go expressions

grun grun is a command-line tool for evaluating Go expressions. It was inspired by runner which does the same for Rust. It constructs a little Go prog

Steve J Donovan 8 Feb 10, 2022
A simple evaluator for arithmetic integer expressions.

The expr package provides a simple evaluator for arithmetic integer expressions. The syntax and operations are the same as in Go. Operands are the nat

Rob Pike 80 Sep 6, 2022
A commandline tool to resolve URI Templates expressions as specified in RFC 6570.

URI Are you tired to build, concat, replace URL(s) (via shell scripts sed/awk/tr) from your awesome commandline pipeline? Well! here is the missing pi

Luca Sepe 17 Jun 9, 2021
Transform PromQL Expressions on the fly

promql-transform Transforms PromQL expressions on the fly Usage Given the expression job:request_latency_seconds:mean5m{job=\"myjob\"} > 0.5 Running

Canonical 1 Jun 21, 2022
A small & fast dependency-free library for parsing micro expressions.

MicroExpr A small & fast dependency-free library for parsing micro expressions. This library was originally built for use in templating languages (e.g

Daniel G. Taylor 9 Oct 30, 2022
An extremely fast Go (golang) HTTP router that supports regular expression route matching. Comes with full support for building RESTful APIs.

ozzo-routing You may consider using go-rest-api to jumpstart your new RESTful applications with ozzo-routing. Description ozzo-routing is a Go package

Ozzo Framework 445 Nov 15, 2022
rxscan provides functionality to scan text to variables using regular expression capture group.

rxscan rxscan provides functionality to scan text to variables using regular expression capture group. This library is still experimental, use at your

Ahmy Yulrizka 14 Dec 21, 2020
chkb turns a regular keyboard into a fully programmable keyboard. It is a cheap programmable keyboard

chkb chkb turns a regular keyboard intro a fully programmable keyboard. So you basically get a cheap programmable keyboard. It has been inspired by QM

Victor 33 Oct 2, 2022
A CLI tool that you can use create regular backups of your Notion.so Pages.

notion-offliner A CLI tool that you can use create regular backups of your Notion.so Pages. Perfect for disaster scenarios and offline usage. MacOS an

Ned McClain 10 Apr 18, 2022