idea驼峰下划线转换
模式串
(\w*)_(\w*)
- 1
捕获组加大写转换
\$1\u$2
- 1
说明: $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 =
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
= result
Next c
End Sub
说明: xVAT会被转换成x_v_a_t, 使用是有可以注意一下, 自己也可以修改下算法针对性兼容, 不过感觉没有必须, 有这种数据场景应该不多
excel下划线转驼峰[函数]
=LOWER(LEFT(SUBSTITUTE(PROPER(A1),"_",""),1))&RIGHT(SUBSTITUTE(PROPER(A1),"_",""),LEN(SUBSTITUTE(PROPER(A1),"_",""))-1)
或者这样
=LEFT(A1,1)&MID(SUBSTITUTE(PROPER(A1),"_",""),2,100)
- 1
- 2
- 3
- 4
excel下划线转驼峰[宏]
Sub UnderlineToCamel()
Dim cell As Range
For Each cell In Selection
= (Replace(, "_", " "))
= Replace(, " ", "")
Next cell
End Sub
- 1
- 2
- 3
- 4
- 5
- 6
- 7