2020-04-03 06:36:09 +03:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2022-12-12 20:10:43 +03:00
|
|
|
|
|
|
|
"git.internal/re/stringy"
|
2020-04-03 06:36:09 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-04-05 16:10:08 +03:00
|
|
|
strBetween := stringy.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
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
teaseString := stringy.New("Hello My name is Roshan. I am full stack developer")
|
2020-04-05 15:57:30 +03:00
|
|
|
fmt.Println(teaseString.Tease(20, "..."))
|
2020-04-05 12:11:56 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
replaceFirst := stringy.New("Hello My name is Roshan and his name is Alis.")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(replaceFirst.ReplaceFirst("name", "nombre"))
|
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
replaceLast := stringy.New("Hello My name is Roshan and his name is Alis.")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(replaceLast.ReplaceLast("name", "nombre"))
|
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
snakeCase := stringy.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 15:57:30 +03:00
|
|
|
fmt.Println(snakeCase.SnakeCase("?", "").ToUpper())
|
|
|
|
fmt.Println(snakeCase.SnakeCase("?", "").ToLower())
|
2020-04-05 12:11:56 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
camelCase := stringy.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
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
delimiterString := stringy.New("ThisIsOne___messed up string. Can we Really delimeter-case It?")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(delimiterString.Delimited("?").Get())
|
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
contains := stringy.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
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
lines := stringy.New("fòô\r\nbàř\nyolo123")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(lines.Lines())
|
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
reverse := stringy.New("This is only test")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(reverse.Reverse())
|
2020-04-03 06:36:09 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
pad := stringy.New("Roshan")
|
2020-04-05 15:57:30 +03:00
|
|
|
fmt.Println(pad.Pad(10, "0", "both"))
|
|
|
|
fmt.Println(pad.Pad(10, "0", "left"))
|
|
|
|
fmt.Println(pad.Pad(10, "0", "right"))
|
2020-04-03 06:36:09 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
shuffleString := stringy.New("roshan")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(shuffleString.Shuffle())
|
2020-04-03 06:36:09 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
cleanString := stringy.New("special@#remove%%%%")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(cleanString.RemoveSpecialCharacter())
|
2020-04-03 06:36:09 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
boolString := stringy.New("off")
|
2020-04-05 12:11:56 +03:00
|
|
|
fmt.Println(boolString.Boolean())
|
2020-04-03 06:36:09 +03:00
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
surroundStr := stringy.New("__")
|
2020-04-05 15:57:30 +03:00
|
|
|
fmt.Println(surroundStr.Surround("-"))
|
|
|
|
|
2020-04-05 16:10:08 +03:00
|
|
|
str := stringy.New("hello__man how-Are you??")
|
2020-04-05 15:57:30 +03:00
|
|
|
result := str.CamelCase("?", "")
|
|
|
|
fmt.Println(result) // HelloManHowAreYou
|
|
|
|
|
|
|
|
snakeStr := str.SnakeCase("?", "")
|
|
|
|
fmt.Println(snakeStr.ToLower()) // hello_man_how_are_you
|
|
|
|
|
|
|
|
kebabStr := str.KebabCase("?", "")
|
|
|
|
fmt.Println(kebabStr.ToUpper()) // HELLO-MAN-HOW-ARE-YOU
|
|
|
|
|
2020-04-07 07:57:58 +03:00
|
|
|
fcn := stringy.New("4111 1111 1111 1111")
|
|
|
|
first := fcn.First(4)
|
|
|
|
fmt.Println(first) // 4111
|
|
|
|
|
|
|
|
lcn := stringy.New("4111 1111 1111 1348")
|
|
|
|
last := lcn.Last(4)
|
|
|
|
fmt.Println(last) // 1348
|
|
|
|
|
2021-05-14 13:41:41 +03:00
|
|
|
ufo := stringy.New("known flying object")
|
|
|
|
fmt.Println(ufo.Prefix("un")) // unknown flying object
|
|
|
|
|
|
|
|
pun := stringy.New("this really is a cliff")
|
|
|
|
fmt.Println(pun.Suffix("hanger")) // this really is a cliffhanger
|
2020-04-05 12:11:56 +03:00
|
|
|
}
|