Sobes.tech
Intern

/** :-))) :-(( "ab :-)" = "ab " "ab :-)))" = "ab " "ab :-)))(" = "ab (" "ab ):-)" = "ab )" ":-)" = "" **/ func deleteP(str string) string { }

sobes.tech AI

Answer from AI

The function should remove all occurrences of smileys in the format ":-)" with any number of ")" after the colon and hyphen, for example ":-)", ":-)))" and so on. However, if a "(" symbol follows the smiley, it should remain.

Implementation in Go using regular expressions:

import (
	"regexp"
)

func deleteP(str string) string {
	re := regexp.MustCompile(`:-\)+`)
	return re.ReplaceAllString(str, "")
}

Example:

fmt.Println(deleteP(":-)))"))       // ""
fmt.Println(deleteP("ab :-)"))     // "ab "
fmt.Println(deleteP("ab :-)))("))  // "ab ("
fmt.Println(deleteP("ab ):-)"))    // "ab )"