Filter löschen
Filter löschen

Split column by text and numbers

7 Ansichten (letzte 30 Tage)
Dion Theunissen
Dion Theunissen am 10 Aug. 2022
Beantwortet: Stephen23 am 10 Aug. 2022
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",...]
  1 Kommentar
Walter Roberson
Walter Roberson am 10 Aug. 2022
https://www.mathworks.com/help/matlab/ref/extract.html

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Stephen23
Stephen23 am 10 Aug. 2022
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"

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by