go - Golang - Removing all Unicode newline characters from a string -


how remove unicode newlines utf-8 string in golang? found this answer php.

you can use strings.map:

func filternewlines(s string) string {     return strings.map(func(r rune) rune {         switch r {         case 0x000a, 0x000b, 0x000c, 0x000d, 0x0085, 0x2028, 0x2029:             return -1         default:             return r         }     }, s) } 

playground


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -