Web/GoLang
Golang의 문자열에서 개행 문자를 제거하는 방법 \r\n \n
벨포트조던
2023. 1. 10. 18:10
반응형
package main
import (
"fmt"
"strings"
)
func main() {
var string_a string = "My super \nsweet \nstring has \nmany newline\n characters"
fmt.Println(string_a)
var string_b string = string_a
string_b = strings.Replace(string_b, "\n", "", -1)
fmt.Println(string_b)
}
또는
string_b = strings.Replace(string_b, "\r\n", "", -1)
|
참고
https://topherpedersen.blog/2020/02/03/how-to-strip-newline-characters-from-a-string-in-golang/
How to Strip Newline Characters from a String in Golang | topherpedersen.blog
This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a b
topherpedersen.blog
https://gist.github.com/topherPedersen/a6d1f4f9a9e95852a3d1907b4e505625
반응형