Skip to content

Instantly share code, notes, and snippets.

Created May 7, 2012
What would you like to do?
(defun un-camelcase-string (s &optional sep start)
"Convert CamelCase string S to lower case with word separator SEP.
Default for SEP is a hyphen \"-\".
If third argument START is non-nil, convert words after that
index in STRING."
(let ((case-fold-search nil))
(while (string-match "[A-Z]" s (or start 1))
(setq s (replace-match (concat (or sep "-")
(downcase (match-string 0 s)))
t nil s)))
(downcase s)))
# -*- mode: snippet -*-
# key: ut
# name: ut
# expand-env: ((yas/indent-line 'fixed))
# --
class Test${1:Foo}(BaseTestCase):
def setUp(self):
super(Test$1, self).setUp()
def tearDown(self):
super(Test$1, self).tearDown()
def test_should_${1:$(un-camelcase-string text "_")}(self):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment