How can I trim these strings according to the underscores

9 Ansichten (letzte 30 Tage)
Chiara Scarpellini
Chiara Scarpellini am 25 Jul. 2021
Kommentiert: Chunru am 26 Jul. 2021
I need to trim these strings according to the underscores, basically from every string I need to obtain 5 pieces
Novana_Model_B180_DK1_4284.0
Novana_Model_ALSTED_AA_DK1_7835.166666666666
Novana_model_Storaa_DK3_11535.0
DK_QNP_Aa51200001_DK3_1469.143
Novana_Model_MOELLERENDE_DK1_492.42857142857144
DK_QNP_Aa51200001_DK3_979.429
Novana_Model_MOELLERENDE_DK1_984.8571428571429
DK_QNP_Aa51200062_DK3_1961.2
DK_QNP_Aa51200062_DK3_4412.7
DK_QNP_Aa51200062_DK3_2451.5
Novana_model_Branch_73_DK3_1263.75
DK_QNP_Aa51200062_DK3_4412.7
Novana_model_Branch_73_DK3_1263.75
  2 Kommentare
Chiara Scarpellini
Chiara Scarpellini am 26 Jul. 2021
What if I want now to merge the part before the DK and keep the numbers at the end separated?
NovanaModelB180 4284.0
NovanaModelALSTEDAA 7835.166666666666

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chunru
Chunru am 25 Jul. 2021
Bearbeitet: Chunru am 26 Jul. 2021
str = "Novana_Model_B180_DK1_4284.0"
str = "Novana_Model_B180_DK1_4284.0"
str1 = strsplit(str, '_')
str1 = 1×5 string array
"Novana" "Model" "B180" "DK1" "4284.0"
join(str1(1:4), '')
ans = "NovanaModelB180DK1"

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by