All Projects → ozgio → Strutil

ozgio / Strutil

Licence: mit
String utilities for Go

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Labels

Projects that are alternatives of or similar to Strutil

Sweep
Fast and powerful Swift string scanning made simple
Stars: ✭ 485 (+325.44%)
Mutual labels:  strings
Cracking The Coding Interview
Solutions for Cracking the Coding Interview - 6th Edition
Stars: ✭ 35 (-69.3%)
Mutual labels:  strings
Str metrics
Ruby gem (native extension in Rust) providing implementations of various string metrics
Stars: ✭ 68 (-40.35%)
Mutual labels:  strings
Glue
Glue strings to data in R. Small, fast, dependency free interpreted string literals.
Stars: ✭ 512 (+349.12%)
Mutual labels:  strings
Mightystring
Making Ruby Strings Powerful
Stars: ✭ 28 (-75.44%)
Mutual labels:  strings
Golang Combinations
Golang library which provide an algorithm to generate all combinations out of a given string array.
Stars: ✭ 51 (-55.26%)
Mutual labels:  strings
Philology
An easy way to dynamically replace Strings of your Android App or provide new languages Over-the-air without needed to publish a new release on Google Play.
Stars: ✭ 458 (+301.75%)
Mutual labels:  strings
Algorithms
A collection of algorithms and data structures
Stars: ✭ 11,553 (+10034.21%)
Mutual labels:  strings
Coding Ninjas Java Solutions
This will have solutions to all the problems that are included in Coding Ninja's 2020 Java Course. Star the repo if you like it.
Stars: ✭ 32 (-71.93%)
Mutual labels:  strings
Stringer
Generate Android & iOS localized strings from a csv.
Stars: ✭ 60 (-47.37%)
Mutual labels:  strings
Xstrings
Implements string functions widely used in other languages but absent in Go.
Stars: ✭ 888 (+678.95%)
Mutual labels:  strings
Frosty
serialize native Nim types to strings, streams, or sockets ⛄
Stars: ✭ 25 (-78.07%)
Mutual labels:  strings
Cello
A string library
Stars: ✭ 54 (-52.63%)
Mutual labels:  strings
Twine
String manipulation, leveled up!
Stars: ✭ 496 (+335.09%)
Mutual labels:  strings
Random
Generate random strings or numeric values
Stars: ✭ 68 (-40.35%)
Mutual labels:  strings
Stringsifter
A machine learning tool that ranks strings based on their relevance for malware analysis.
Stars: ✭ 469 (+311.4%)
Mutual labels:  strings
Pgo
Go library for PHP community with convenient functions
Stars: ✭ 51 (-55.26%)
Mutual labels:  strings
Strings
A set of useful functions for transforming strings.
Stars: ✭ 111 (-2.63%)
Mutual labels:  strings
Algorithms Study Group
Study group for algorithms in Ruby, hosted at App Academy
Stars: ✭ 94 (-17.54%)
Mutual labels:  strings
Simplebolt
🔩 Simple way to use the Bolt database
Stars: ✭ 58 (-49.12%)
Mutual labels:  strings

String Utilities for Go

CircleCI GoReportCard GoDocs

"strutil" provides string functions for go applications.

For documentation with examples see GoDoc

Functions

Align (Docs)

Aligns the text to the specified side

strutil.Align("lorem ipsum", strutil.Right, 20) //->"        lorem ipsum" 

AlignCenter (Docs)

Aligns the text to the center

strutil.AlignCenter("lorem\nipsum", 10) //->"  lorem   \n  ipsum   " 

AlignLeft (Docs)

Aligns the text to the left

strutil.AlignLeft("  lorem   \n  ipsum   ") //->"lorem   \nipsum   " 

AlignRight (Docs)

Aligns the text to the right

strutil.AlignRight("lorem\nipsum", 10) //-> "     lorem\n     ipsum" 

CountWords (Docs)

Counts the words

strutil.CountWords("Lorem ipsum, dolor sit amet") //-> "5"

DrawBox (Docs)

Draws a frame around the string with default character set

strutil.DrawBox("Hello World", 20, strutil.Center)
//┌──────────────────┐
//│   Hello World    │
//└──────────────────┘

DrawCustomBox (Docs)

Draws a frame around the string with custom character set

strutil.DrawCustomBox("Hello World", 20, strutil.Center, strutil.SimpleBox9Slice(), "\n")
//┌──────────────────┐
//│   Hello World    │
//└──────────────────┘

ExpandTabs (Docs)

Converts tabs to the spaces

strutil.ExpandTabs("\tlorem\n\tipsum\n", 2) //-> "  lorem\n  ipsum\n"

Indent (Docs)

Indents every line

strutil.Indent("lorem\nipsum", "> ") //-> "> lorem\n> ipsum"

IsASCII (Docs)

Checks if all the characters in string are in standard ASCII table

strutil.IsASCII("lorem\nipsum") //-> true

Len (Docs)

Alias of utf8.RuneCountInString which returns the number of runes in string

strutil.Len("böt") //-> "3"

MapLines (Docs)

Runs function fn on every line of the string

strutil.MapLines("   lorem      \n    ipsum      ", strings.TrimSpace) //-> "lorem\nipsum"

OSNewLine (Docs)

OSNewLine returns operating systems default new line character

strutil.OSNewLine() //-> "\n"

Pad (Docs)

Left and right pads the string

strutil.Pad("lorem", 11, "->", "<-") //-> "->->lorem<-<-"

PadLeft (Docs)

Left pads the string

strutil.PadLeft("lorem", 9, "->") //-> "->->lorem"

PadRight (Docs)

Right pads the string

strutil.PadRight("lorem", 9, "<-") //-> "lorem<-<-"

Random (Docs)

Creates a random string from a character set

strutil.Random("abcdefghi", 10) //-> "aciafbeafg"

RemoveAccents (Docs)

Convert accented letters to ascii counterparts

strutil.RemoveAccents("résumé") //-> "resume"

ReplaceAllToOne (Docs)

Replace all substrings in the text with the specified string

strutil.ReplaceAllToOne("lorem ipsum", []string{"o","e","i","u"}, ".") //-> "l.r.m .ps.m"

Reverse (Docs)

Reverses the string

strutil.Reverse("lorem") //-> "merol"

Splice (Docs)

Replaces a part of the string

strutil.Splice("lorem", "-x-", 2, 3) //-> "lo-x-em"

SplitAndMap (Docs)

Splits the string and runs the function fn on every part

strutil.MapLines("lorem-ipsum-dolor", "-",  strutil.Reverse) //-> "merol\nmuspi\nrolod"

Slugify (Docs)

Converts the string to a slug

strutil.Slugify("Lorem ipsum, dolör") //-> "lorem-ipsum-dolor"

SlugifySpecial (Docs)

Converts the string to a slug with custom delimiter.

strutil.SlugifySpecial("Lorem ipsum, dolör", "_") //-> "lorem_ipsum_dolor"

SplitCamelCase (Docs)

Splits the words in a camelCase string

strutil.SplitCamelCase("loremIpsum") //-> []string{"lorem", "Ipsum"}

Substring (Docs)

Gets a part of the string without panics

strutil.SafeSubstring("lorem", 0, 1) //-> "l"

MustSubstring (Docs)

Gets a part of the string

strutil.Substring("lorem", 0, 1) //-> "l"

Summary (Docs)

Cuts the string to the specified length

strutil.Summary("Lorem ipsum dolor sit amet",  10, "...") //-> "lorem ipsum..."

Tile (Docs)

Repeats the pattern until the result reaches the 'length'

strutil.Tile("-৹", 4) //-> "-৹-৹"

ToSnakeCase (Docs)

Converts the string to snake_case

strutil.ToSnakeCase("Snake Case") //-> "snake_case"

ToCamelCase (Docs)

Converts the string to camelCase

strutil.ToCamelCase("Camel Case") //-> "camelCase"

Words (Docs)

Returns the words inside the text

strutil.Words("Lorem ipsum, dolor sit amet") //-> []string{"Lorem", "ipsum", "dolor", "sit", "amet"}

WordWrap (Docs)

Wraps the lines in the text

strutil.WordWrap("Lorem ipsum dolor sit amet", 15, false) //-> "Lorem ipsum\ndolor sit amet"

Install

Prequsities:

  • Go 1.10+

Install with

go get github.com/ozgio/strutil
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].