[go] 문자열에서 알파벳만 추출

package main

import ( “fmt” “unicode” )

func main() { str := “Hello, 123_월드!”

var result string
for _, char := range str {
	if unicode.IsLetter(char) {
		result += string(char)
	}
}

fmt.Println(result) } ```

위의 예시는 Go 언어를 사용하여 주어진 문자열에서 알파벳만 추출하는 방법을 보여줍니다. unicode 패키지를 이용하여 문자열을 순회하면서 IsLetter 함수를 사용하여 알파벳인 경우에만 결과에 추가하고 나머지 문자는 무시합니다. 결과는 “Hello월드”가 출력됩니다.