stringy/example/main.go

55 lines
1.5 KiB
Go
Raw Normal View History

2020-04-03 06:36:09 +03:00
package main
import (
"fmt"
2020-04-05 12:11:56 +03:00
. "github.com/gobeam/Stringy"
2020-04-03 06:36:09 +03:00
)
func main() {
2020-04-05 12:11:56 +03:00
strBetween := New("HelloMyName")
2020-04-05 14:02:47 +03:00
fmt.Println(strBetween.Between("hello", "name").ToUpper())
2020-04-05 12:11:56 +03:00
teaseString := New("Hello My name is Roshan. I am full stack developer")
2020-04-05 14:02:47 +03:00
fmt.Println(teaseString.Tease(100, "..."))
2020-04-05 12:11:56 +03:00
replaceFirst := 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.")
fmt.Println(replaceLast.ReplaceLast("name", "nombre"))
snakeCase := New("ThisIsOne___messed up string. Can we Really Snake Case It?")
2020-04-05 14:02:47 +03:00
fmt.Println(snakeCase.SnakeCase("?", "").Get())
2020-04-05 12:11:56 +03:00
camelCase := New("ThisIsOne___messed up string. Can we Really camel-case It ?##")
2020-04-05 14:02:47 +03:00
fmt.Println(camelCase.CamelCase("?", "", "#", ""))
2020-04-05 12:11:56 +03:00
delimiterString := New("ThisIsOne___messed up string. Can we Really delimeter-case It?")
fmt.Println(delimiterString.Delimited("?").Get())
contains := New("hello mam how are you??")
2020-04-05 14:02:47 +03:00
fmt.Println(contains.ContainsAll("mams", "?"))
2020-04-05 12:11:56 +03:00
lines := New("fòô\r\nbàř\nyolo123")
fmt.Println(lines.Lines())
reverse := New("This is only test")
fmt.Println(reverse.Reverse())
2020-04-03 06:36:09 +03:00
2020-04-05 12:11:56 +03:00
pad := New("Roshan")
2020-04-05 14:02:47 +03:00
fmt.Println(pad.Pad(0, "0", "both"))
fmt.Println(pad.Pad(0, "0", "left"))
fmt.Println(pad.Pad(0, "0", "right"))
2020-04-03 06:36:09 +03:00
2020-04-05 12:11:56 +03:00
shuffleString := New("roshan")
fmt.Println(shuffleString.Shuffle())
2020-04-03 06:36:09 +03:00
2020-04-05 12:11:56 +03:00
cleanString := New("special@#remove%%%%")
fmt.Println(cleanString.RemoveSpecialCharacter())
2020-04-03 06:36:09 +03:00
2020-04-05 12:11:56 +03:00
boolString := New("off")
fmt.Println(boolString.Boolean())
2020-04-03 06:36:09 +03:00
2020-04-05 12:11:56 +03:00
}