forked from mirror/stringy
Code cleanup
This commit is contained in:
parent
ac326ac2d7
commit
7a6cec96c2
|
@ -2,61 +2,61 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
. "github.com/gobeam/Stringy"
|
||||
stringy "github.com/gobeam/Stringy"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
strBetween := New("HelloMyName")
|
||||
strBetween := stringy.New("HelloMyName")
|
||||
fmt.Println(strBetween.Between("hello", "name").ToUpper())
|
||||
|
||||
teaseString := New("Hello My name is Roshan. I am full stack developer")
|
||||
teaseString := stringy.New("Hello My name is Roshan. I am full stack developer")
|
||||
fmt.Println(teaseString.Tease(20, "..."))
|
||||
|
||||
replaceFirst := New("Hello My name is Roshan and his name is Alis.")
|
||||
replaceFirst := stringy.New("Hello My name is Roshan and his name is Alis.")
|
||||
fmt.Println(replaceFirst.ReplaceFirst("name", "nombre"))
|
||||
|
||||
replaceLast := New("Hello My name is Roshan and his name is Alis.")
|
||||
replaceLast := stringy.New("Hello My name is Roshan and his name is Alis.")
|
||||
fmt.Println(replaceLast.ReplaceLast("name", "nombre"))
|
||||
|
||||
snakeCase := New("ThisIsOne___messed up string. Can we Really Snake Case It?")
|
||||
snakeCase := stringy.New("ThisIsOne___messed up string. Can we Really Snake Case It?")
|
||||
fmt.Println(snakeCase.SnakeCase("?", "").Get())
|
||||
fmt.Println(snakeCase.SnakeCase("?", "").ToUpper())
|
||||
fmt.Println(snakeCase.SnakeCase("?", "").ToLower())
|
||||
|
||||
camelCase := New("ThisIsOne___messed up string. Can we Really camel-case It ?##")
|
||||
camelCase := stringy.New("ThisIsOne___messed up string. Can we Really camel-case It ?##")
|
||||
fmt.Println(camelCase.CamelCase("?", "", "#", ""))
|
||||
|
||||
delimiterString := New("ThisIsOne___messed up string. Can we Really delimeter-case It?")
|
||||
delimiterString := stringy.New("ThisIsOne___messed up string. Can we Really delimeter-case It?")
|
||||
fmt.Println(delimiterString.Delimited("?").Get())
|
||||
|
||||
contains := New("hello mam how are you??")
|
||||
contains := stringy.New("hello mam how are you??")
|
||||
fmt.Println(contains.ContainsAll("mams", "?"))
|
||||
|
||||
lines := New("fòô\r\nbàř\nyolo123")
|
||||
lines := stringy.New("fòô\r\nbàř\nyolo123")
|
||||
fmt.Println(lines.Lines())
|
||||
|
||||
reverse := New("This is only test")
|
||||
reverse := stringy.New("This is only test")
|
||||
fmt.Println(reverse.Reverse())
|
||||
|
||||
pad := New("Roshan")
|
||||
pad := stringy.New("Roshan")
|
||||
fmt.Println(pad.Pad(10, "0", "both"))
|
||||
fmt.Println(pad.Pad(10, "0", "left"))
|
||||
fmt.Println(pad.Pad(10, "0", "right"))
|
||||
|
||||
shuffleString := New("roshan")
|
||||
shuffleString := stringy.New("roshan")
|
||||
fmt.Println(shuffleString.Shuffle())
|
||||
|
||||
cleanString := New("special@#remove%%%%")
|
||||
cleanString := stringy.New("special@#remove%%%%")
|
||||
fmt.Println(cleanString.RemoveSpecialCharacter())
|
||||
|
||||
boolString := New("off")
|
||||
boolString := stringy.New("off")
|
||||
fmt.Println(boolString.Boolean())
|
||||
|
||||
surroundStr := New("__")
|
||||
surroundStr := stringy.New("__")
|
||||
fmt.Println(surroundStr.Surround("-"))
|
||||
|
||||
str := New("hello__man how-Are you??")
|
||||
str := stringy.New("hello__man how-Are you??")
|
||||
result := str.CamelCase("?", "")
|
||||
fmt.Println(result) // HelloManHowAreYou
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package string_manipulation
|
||||
package stringy
|
||||
|
||||
// const below are used in packages
|
||||
const (
|
||||
First = "first"
|
||||
Last = "last"
|
||||
|
@ -11,5 +12,8 @@ const (
|
|||
ReplaceCapital = "$1 $2"
|
||||
)
|
||||
|
||||
// False is slice of array for false logical representation in string
|
||||
var False = []string{"off", "no", "0", "false"}
|
||||
|
||||
// True is slice of array for true logical representation in string
|
||||
var True = []string{"on", "yes", "1", "True"}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package string_manipulation
|
||||
package stringy
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package string_manipulation
|
||||
package stringy
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
|
Loading…
Reference in New Issue