diff options
| author | Teddy Wing | 2014-11-14 23:22:23 -0500 |
|---|---|---|
| committer | Teddy Wing | 2014-11-14 23:22:23 -0500 |
| commit | 3ace9ccd451ef34a429450b16f46cfd3e974b6cd (patch) | |
| tree | d9fe6576a73fd3cf15d2c4343fea2940781cdf24 | |
| parent | 02b458085c75faa2e8349f9cba4af9a53c00e798 (diff) | |
| download | unXHTMLify-3ace9ccd451ef34a429450b16f46cfd3e974b6cd.tar.bz2 | |
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.
| -rw-r--r-- | unxhtmlify.go | 5 |
1 files 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, ">") } |
