How can I trim these strings according to the underscores

조회 수: 8 (최근 30일)
Chiara Scarpellini
Chiara Scarpellini 2021년 7월 25일
댓글: Chunru 2021년 7월 26일
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
Chiara Scarpellini
Chiara Scarpellini 2021년 7월 26일
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
Chunru
Chunru 2021년 7월 26일
See below.

댓글을 달려면 로그인하십시오.

채택된 답변

Chunru
Chunru 2021년 7월 25일
편집: Chunru 2021년 7월 26일
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"

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by