fork(1) download
  1. import re
  2.  
  3. def convert(name):
  4. return re.sub(r'([A-Z]*)([A-Z][a-z]+)', lambda x: (x.group(1) + '_' if x.group(1) else '') + x.group(2) + '_', name).rstrip('_').lower()
  5.  
  6. print convert('CamelCase')
  7. print convert('HTTP')
  8. print convert('HTTPRequest')
  9. print convert('SecureHTTPRequest')
  10. print convert('SecureHTTP')
  11.  
Success #stdin #stdout 0.03s 44680KB
stdin
Standard input is empty
stdout
camel_case
http
http_request
secure_http_request
secure_http