Permalink
Browse files

Change the hyphenation regexp and add a couple of test cases.

  • Loading branch information...
1 parent 7afa565 commit 02e28312d0444d83ad070481b515f52bef45f333 @brown committed Feb 7, 2012
Showing with 4 additions and 1 deletion.
  1. +2 −1 protoc/protoc.lisp
  2. +2 −0 protoc/protoc_test.lisp
View
@@ -57,7 +57,8 @@
(defun hyphenate-studly-caps (string)
(setf string (cl-ppcre:regex-replace "([A-Z]+)([A-Z][a-z])" string "\\1-\\2"))
- (setf string (cl-ppcre:regex-replace "([a-z0-9])([A-Z])" string "\\1-\\2"))
+ (setf string (cl-ppcre:regex-replace "([a-z])([A-Z])" string "\\1-\\2"))
+ (setf string (cl-ppcre:regex-replace "([0-9])([A-Za-z])" string "\\1-\\2"))
(setf string (cl-ppcre:regex-replace "([A-Za-z])([0-9])" string "\\1-\\2"))
string)
View
@@ -61,5 +61,7 @@
(verify "SpaceX" "space-x")
(verify "RFC1234" "rfc-1234")
(verify "Rfc1234" "rfc-1234")
+ (verify "12am" "12-am")
+ (verify "9PM" "9-pm")
(verify "Html5Manual" "html-5-manual")
(verify "X15Airplane" "x-15-airplane")))

0 comments on commit 02e2831

Please sign in to comment.