Skip to content

Commit

Permalink
Improves the upcase_first_letter() function
Browse files Browse the repository at this point in the history
  • Loading branch information
thomskaf committed Feb 26, 2014
1 parent 81b51e4 commit 29c3366
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
stringhelpers Changelog
=======================

Version 1.2
-----------
Improves the `upcase_first_letter` function.
- Any non-alphanumeric chars and spaces will now not be treated as the first letter,
which stopped the search after the first letter that should be capitalized.


Version 1.1
-----------
Fixes small typos.
Expand Down
6 changes: 4 additions & 2 deletions stringhelpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
:license: MIT, see LICENSE for more details.
"""

__version__ = '1.1'
__version__ = '1.2'

import re
import os
Expand Down Expand Up @@ -39,7 +39,9 @@ def upcase_first_letter(string):
:param :string: string to capitalize first letter of.
"""
return string[0].upper() + string[1:]
alpha = re.compile(r"[^\W\s\d]", re.UNICODE)
letter = alpha.search(string).group()
return string.replace(letter, letter.upper(), 1)


def reverse(string):
Expand Down

0 comments on commit 29c3366

Please sign in to comment.