Giter Club home page Giter Club logo

lualibs's Introduction

LuaLib

A String library for lua

Introduction

LuaLibs is a string library for Lua that provides utility functions for string operations

The project is hosted on GitHub. You can report bugs and discuss features on the issues page, or email to [email protected].

Tests

The tests are available in test folder

How to include

local strl = require "strl"

String Functions

isString

strl.isString(value)

returns true if the given value is a String else returns false

strl.isString("Hello")
=> true
strl.isString(4)
=> false

isEmpty

strl.isEmpty(value)

returns true if value is nil or empty string

strl.isEmpty("Hello")
=> false
strl.isEmpty("")
=> true
strl.isEmpty(nil)
=> false

trim

strl.trim(value)

returns trims leading and trailing whitespaces

strl.trim("  Hello  ")
=> Hello

ltrim

strl.ltrim(value)

returns trims leading whitespaces

strl.ltrim("  Hello")
=> Hello

rtrim

strl.rtrim(value)

returns trims trailing whitespaces

strl.rtrim("Hello   ")
=> Hello

split

strl.split(value,[seperator])

returns a table of string split using the seperator. By default space is the seperator

strl.split("Hello World")
=> {"Hello","World"}
strl.split("Hello-World","-")
=> {"Hello","World"}

splitLines

strl.splitLines(value)

returns a table of string split by line

strl.splitLines("Hello\nWorld")
=> {"Hello","World"}

startsWith

strl.startsWith(value,startsWithValue)

returns true if the first parameter starts with the second paramter.

strl.startsWith("HelloWorld","Hello")
=> true
strl.startsWith("HelloWorld","World")
=> false

endsWith

strl.endsWith(value,endsWithValue)

returns true if the first parameter ends with the second paramter.

strl.endsWith("HelloWorld","World")
=> true
strl.endsWith("HelloWorld","Hello")
=> false

encodeBase64

strl.encodeBase64(value)

returns base 64 encoded string

strl.encodeBase64("test:test123")
=> "dGVzdDp0ZXN0MTIz"

decodeBase64

strl.decodeBase64(value)

returns base 64 decoded string

strl.decodeBase64("dGVzdDp0ZXN0MTIz")
=> "test:test123"

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.