Function ONLYUPPER(s As String) As String
Dim tmp As String
Dim res As String
For i = 1 To Len(s)
tmp = Mid(s, i, 1)
If tmp = "/" Then Exit For
If Asc(tmp) >= 65 And Asc(tmp) <= 90 Then res = res & tmp
Next i
ONLYUPPER = res
End Function
Function RXOnlyUpper(s As String) As String
Dim SP() As String: SP = Split(s, "/")
With CreateObject("VBScript.RegExp")
.Pattern = "[^A-Z]"
.Global = True
RXOnlyUpper = .Replace(SP(0), "")
End With
End Function
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each Text.Combine(List.RemoveNulls(List.Transform(Text.ToList(Text.BeforeDelimiter([Raw],"/")), each if Character.ToNumber(_) >=65 and Character.ToNumber(_) <=90 then _ else null))))
in
#"Added Custom"
(txt as text) =>
let
Source = txt,
Custom = Text.Combine(List.RemoveNulls(List.Transform(Text.ToList(Text.BeforeDelimiter(Source,"/")), each if Character.ToNumber(_) >=65 and Character.ToNumber(_) <=90 then _ else null)))
in
Custom
[SIZE=1]// Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
T2R = Table.AddColumn(Source, "Text", each Text.Combine(List.RemoveItems(Text.ToList([Input]),{"0".."9","a".."z","/","_","."," "})))
in
T2R[/SIZE]
Here is a more compact way to write your non-RegExp UDF (user defined function)...Welcome to the forum. Give this UDF a shot.
Code:Function ONLYUPPER(s As String) As String Dim tmp As String Dim res As String For i = 1 To Len(s) tmp = Mid(s, i, 1) If tmp = "/" Then Exit For If Asc(tmp) >= 65 And Asc(tmp) <= 90 Then res = res & tmp Next i ONLYUPPER = res End Function
Function ONLYUPPER(S As String) As String
Dim X As Long
For X = 1 To InStr(S, "/") + 1
If Mid(S, X, 1) Like "[A-Z]" Then ONLYUPPER = ONLYUPPER & Mid(S, X, 1)
Next
End Function
Should be:For X = 1 To InStr(S, "/") + 1
Yep!Should be:
For X = 1 To InStr(S, "/") - 1