Uppercase any non-words (words w/o vowels aeiouy)

* This lets us find accronyms easily, example:
db, ssn, tx, etc.
This commit is contained in:
Patrick O'brien 2016-08-15 19:51:00 +10:00
parent 76d4b84019
commit 984e5f9bac
2 changed files with 6 additions and 1 deletions

View file

@ -15,7 +15,7 @@ import (
var (
idAlphabet = []byte("abcdefghijklmnopqrstuvwxyz")
uppercaseWords = regexp.MustCompile(`^(?i)(id|uid|db|uuid|guid|ssn|tz)[0-9]*$`)
uppercaseWords = regexp.MustCompile(`^(?i)(id|uid|uuid|guid|[^aeiouy]*)[0-9]*$`)
smartQuoteRgx = regexp.MustCompile(`^(?i)"?[a-z_][_a-z0-9]*"?(\."?[_a-z][_a-z0-9]*"?)*(\.\*)?$`)
)

View file

@ -163,6 +163,11 @@ func TestTitleCase(t *testing.T) {
{"guid_thing", "GUIDThing"},
{"thing_guid_thing", "ThingGUIDThing"},
{"id", "ID"},
{"gvzxc", "GVZXC"},
{"id_trgb_id", "IDTRGBID"},
{"vzxx_vxccb_nmx", "VZXXVXCCBNMX"},
{"thing_zxc_stuff_vxz", "ThingZXCStuffVXZ"},
{"zxc_thing_vxz_stuff", "ZXCThingVXZStuff"},
}
for i, test := range tests {