Created
April 12, 2016 11:51
-
-
Save tpdns90321/7c9f753bb5a24a5db6bd89b7962cfc30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SplitLineRe | |
import "regexp" | |
func SplitLineRe(raw string) []string{ | |
return regexp.MustCompile("((\r)\n)").Split(raw,-1) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package SplitLineRe | |
import "fmt" | |
func ExampleSplitLineRe(){ | |
raw := "Hello, WOrld,\r\nWe are the world\nhello" | |
for _,x := range SplitLineRe(raw){ | |
fmt.Println(x) | |
} | |
//Output: | |
//Hello, WOrld, | |
//We are the world | |
//hello | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment