Split column by text and numbers

6 次查看(过去 30 天)
I have a column with housenumbers. Like:
str = ["54","33", "104A",...]
I want to split it in two columns
Numbers = ["54","33", "104",...]
Letters = ["","", "A",...]

采纳的回答

Stephen23
Stephen23 2022-8-10
str = ["54","33","104A"];
tkn = regexp(str,'^(\d+)\s*(\w*)$','tokens','once');
tkn = vertcat(tkn{:});
num = tkn(:,1)
num = 3×1 string array
"54" "33" "104"
let = tkn(:,2)
let = 3×1 string array
"" "" "A"

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by