This is Emacs LISP code. Only tested on GNU Emacs 22.1, but should work on almost any Emacs version.
1 (defun un-camelcase-string (s &optional sep start)
2 "Convert CamelCase string S to lower case with word separator SEP.
3 Default for SEP is a hyphen \"-\".
4
5 If third argument START is non-nil, convert words after that
6 index in STRING."
7 (let ((case-fold-search nil))
8 (while (string-match "[A-Z]" s (or start 1))
9 (setq s (replace-match (concat (or sep "-")
10 (downcase (match-string 0 s)))
11 t nil s)))
12 (downcase s)))
13
14 (defun un-camelcase-string-recursively (s &optional sep start)
15 "Convert CamelCase string S to lower case with word separator SEP.
16 Default for SEP is a hyphen '-'.
17
18 If third argument START is non-nil, convert words after that
19 index in STRING.
20
21 This is the same as `uncamelcase-string', but using a tail-recursive algorithm."
22 (let ((case-fold-search nil))
23 (if (not (string-match "[A-Z]" s (or start 1)))
24 (downcase s)
25 ;; substitute one match, then recurse
26 (un-camelcase-string-recursively (replace-match (concat (or sep "-")
27 (downcase (match-string 0 s)))
28 t nil s)
29 (or sep "-")
30 (match-end 0)))))
Pages : 1