https://go.dev/play/p/F6gNFWjRzGO
On Thursday, December 29, 2022 at 12:50:34 PM UTC-5 Mitul sharma wrote:
> Hello,
>
> I'm stuck in below code snippet, looking to have a output as string
> without any digits.
> Input : "H1e5ll0o"
> Output: "Hello"
>
> I tried with *output := strings.Replace(str, "1", "", -1)*, but it can
> replace only single digit at a time
>
> I'm looking for suggestions for below code snippet , tried to implement a
> logic where string converted to rune and rune provided
> as a input to IsDigit(), if it is digit it should replace the digit with
> "" and print the string , i'm not sure what mistake am i doing in providing
> parameter
> and printing output?
>
> var output string
>
> var r rune
> for _, r = range input {
> break
> }
>
> if unicode.IsDigit(rune(r)) {
> output = strings.Replace(input, "", "", -1)
> fmt.Println(output)
> }else{
> fmt.Println(input)
> }
>
>
>
> On Saturday, 15 January 2011 at 01:31:08 UTC+5:30 Russ Cox wrote:
>
>> There is also strings.Map.
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/31843500-9c1c-4def-8b79-671d6a57484fn%40googlegroups.com.