idea驼峰下划线转换
模式串
(\w*)_(\w*)
捕获组加大写转换
\$1\u$2
说明: $1表示第一个捕获组, $0便是这个字符串, \u是下一个字符转化成大写, 对应的\l是小写
excel驼峰转下划线[宏命令]
Sub CamelToUnderline()
Dim c As Range
For Each c In Selection
Dim result As String
result = “”
Dim str As String
str = c.Value
For i = 1 To Len(str)
Dim currentLetter As String
currentLetter = Mid(str, i, 1)
If i = 1 Then
result = result & LCase(currentLetter)
ElseIf currentLetter = UCase(currentLetter) Then
result = result & “_” & LCase(currentLetter)
Else
result = result & currentLetter
End If
Next i
c.Value = result
Next c
End Sub
说明: xVAT会被转换成x_v_a_t, 使用是有可以注意一下, 自己也可以修改下算法针对性兼容, 不过感觉没有必须, 有这种数据场景应该不多