9 lines
190 B
Python
9 lines
190 B
Python
import re
|
|
from typing import Optional
|
|
|
|
|
|
def camel_to_snake(string: Optional[str]) -> str:
|
|
if not string:
|
|
return string
|
|
return re.sub(r"(?<!^)(?=[A-Z])", "_", string).lower()
|