From 3ace9ccd451ef34a429450b16f46cfd3e974b6cd Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 14 Nov 2014 23:22:23 -0500 Subject: unxhtmlify.go: Use regex replacement Use regex to search for the slash bracket of a self-closing tag. Tests pass, wow. Was not expecting that. I think I need to add more test cases. --- unxhtmlify.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unxhtmlify.go b/unxhtmlify.go index 4e7b175..7013d74 100644 --- a/unxhtmlify.go +++ b/unxhtmlify.go @@ -4,7 +4,7 @@ import ( "bufio" "fmt" "os" - "strings" + "regexp" ) func main() { @@ -18,5 +18,6 @@ func main() { } func unxhtmlify_line(s string) string { - return strings.Replace(s, " /", "", 1) + re := regexp.MustCompile(" ?/>") + return re.ReplaceAllString(s, ">") } -- cgit v1.2.3