The following Go code snippet will convert a string from this:

Wow! This message's getting some _good_ publicity!

To this:

wow-this-messages-getting-some-good

The function

The function itself, and its imports:

import (
    "math"
    "regexp"
    "strings"
)

// Converts a string to a lowercase, hyphen-separated string of max length 36
func getTitleURLFromString(title string) (output string) {
    // first, strip out any special characters
    re := regexp.MustCompile(`(?m)[^\d^A-Z^a-z^\-^\s]`)
    substitution := ""
    output = re.ReplaceAllString(title, substitution)

    // set to lowercase
    output = strings.ToLower(output)

    // next, replace all whitespace characters with dashes
    re = regexp.MustCompile(`(?m)[\s]`)
    substitution = "-"
    output = re.ReplaceAllString(output, substitution)

    // replace "clumps" of 2 or more hyphens with 1 hyphen
    re = regexp.MustCompile(`(?m)-{2,}`)
    substitution = "-"
    output = re.ReplaceAllString(output, substitution)

    // result is only up to 36 characters (or the whole thing if less than 36)
    output = output[:int(math.Min(float64(len(output)), 36))]

    // remove trailing hyphens from the final output
    re = regexp.MustCompile(`(?m)-*$`)
    substitution = ""
    output = re.ReplaceAllString(output, substitution)

    return output
}

Unit tests

package main

import (
    "testing"

    "github.com/stretchr/testify/assert"
)

func TestGetTitleURLFromString(t *testing.T) {
    tests := []struct {
        input    string
        expected string
    }{
        {
            "'''@@)(*F)(*)(*#)(@)(*@#$%&)(@#*$",
            "f",
        },
        {
            "ugly text here!!!??",
            "ugly-text-here",
        },
        {
            "hyphenated-but - still-good!",
            "hyphenated-but-still-good",
        },
        {
            "hyphen at the end should go away and this should be 36 characters)(SD&*-",
            "hyphen-at-the-end-should-go-away-and",
        },
        {
            "Wow! This message's getting some _good_ publicity!",
            "wow-this-messages-getting-some-good",
        },
    }

    for _, test := range tests {
        actual := getTitleURLFromString(test.input)
        assert.Equal(t, test.expected, actual)
    }
}

Final note

Go Playground Link

Additionally, regex101.com is a great resource for interactively testing regular expressions, and it includes a Golang (plus other languages) source code generator to make this process easy.