Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
devwiki:python [2019/01/10 01:30]
ying [re]
devwiki:python [2019/01/10 01:38] (current)
ying [re]
Line 1074: Line 1074:
  
 def convert2(name,​ gap='​_'​):​ def convert2(name,​ gap='​_'​):​
-    return re.sub(r'(?!^)(?<!'​+gap+'​)([A-Z])',​ gap+r'​\1'​) # main conversion+    return re.sub('​((?<​=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))', gap+r'​\1'​, name) # main conversion
 </​code>​ </​code>​
 ===== requests ===== ===== requests =====