6 examples of 'replace space with underscore python' in Python

Every line of 'replace space with underscore python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
14def underscore(value):
15 ''' Convert dots to underscore in a string '''
16 return value.replace('.', '_')
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

23def underscore(word):
24 word = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', word)
25 word = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', word)
26 word = word.replace("-", "_")
27
28 return word.lower()
71def underscore_style(c):
72 return c.replace(" ","_").lower()
22def underscore(name):
23 return re.sub(r' ', r'_', name).lower()
241def underscore(string):
242 sanitzed_string = _string_sanity_check(string)
243 replaced = re.sub(r"([A-Z]+)([A-Z][a-z])", r'\1_\2', sanitzed_string)
244 replaced = re.sub(r"([a-z\d])([A-Z])", r'\1_\2', replaced)
245 return replaced.replace("-", "_").lower()
20def underscore(name):
21 return re.sub('([A-Z]+)', r'_\1', name).strip('_').lower()

Related snippets