Skip to content

Commit 93faadd

Browse files
author
BLACKBEARDSOUL
committed
Fix #140: camel_to_snake adds underscore after digits
Fixed regex to add underscore between digit sequences and uppercase letters. Example: camel_to_snake('python2Thing') now returns 'python2_thing' instead of 'python2thing'.
1 parent c6625dd commit 93faadd

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/graphql/pyutils/convert_case.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
__all__ = ["camel_to_snake", "snake_to_camel"]
88

9-
_re_camel_to_snake = re.compile(r"([a-z]|[A-Z0-9]+)(?=[A-Z])")
9+
_re_camel_to_snake = re.compile(r"([a-z]|[A-Z0-9]+(?=[A-Z])|[0-9]+)(?=[A-Z])")
1010
_re_snake_to_camel = re.compile(r"(_)([a-z\d])")
1111

1212

0 commit comments

Comments
 (0)