GithubHelp home page GithubHelp logo

hartl3y94 / numero-go Goto Github PK

View Code? Open in Web Editor NEW

This project forked from faridgh1991/numero-go

0.0 0.0 0.0 17 KB

A micro library for converting non-english digits in Go.

License: MIT License

Go 100.00%

numero-go's Introduction

Numero-Go

Build Status Go Report Card GoDoc license

A micro library for converting non-english UTF8 digits. (like ۱=1, ۲=2)

Supported languages

Almost all numbers defined in Unicode are support in Numero.

For more info on supported characters you can visit here

Installation

Use go get on this repository:

$ go get -u github.com/faridgh1991/Numero-Go

Using Numero

On strings for strings:

result = numero.Normalize("1۲۳۰4a۳tس")
// result = "12304a3tس"

Smart numeric convert:

(Convert numbers to Integer or Float based on input string)

result, err = numero.NormalizeAsNumber("1۲۳۰4۳")
// result = 123043
// err = nil

result, err = numero.NormalizeAsNumber("1۲۳۰4۳.۴5")
// result = 123043.45
// err = nil

result, err = numero.NormalizeAsNumber("1۲a۳۰4۳.۴5")
// result = 0
// err = parsing "1۲a۳۰4۳.۴5": invalid syntax

Strip all non numeric chars from a string:

result = numero.RemoveNonDigits("12 345abs")
// result = "12345"

// Or even make exceptions for some chars like 'a' and ' ' (space)
result = numero.RemoveNonDigits("12 345bas", "a ")
// result = "12 345a"

Checking if a string is all numbers

result = numero.DigitOnly("1234567890")
// result = true

result = numero.DigitOnly("1234567890.a")
// result = false

GoDoc

See godoc page.

numero-go's People

Contributors

faridgh1991 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.