필터 지우기
필터 지우기

文字列から指定数だけ削除

조회 수: 21 (최근 30일)
H.O
H.O 2024년 2월 14일
댓글: Dyuman Joshi 2024년 2월 15일
文字列(string)のうしろから3文字(空白を含む)を削除したいです.
どのようにすると良いでしょうか?
例)
A=
"aaa 01"
"bbb 02"
"aaa 02"
"bbb 03"
"ccc 04"
...
削除→ 
A=
"aaa"
"bbb"
"aaa"
"bbb"
"ccc"
...

채택된 답변

Dyuman Joshi
Dyuman Joshi 2024년 2월 14일
A = ["aaa 01"
"bbb 02"
"aaa 02"
"bbb 03"
"ccc 04"]
A = 5x1 string array
"aaa 01" "bbb 02" "aaa 02" "bbb 03" "ccc 04"
%Number of characters from end to delete
n = 3;
B = extractBefore(A, strlength(A) - n +1)
B = 5x1 string array
"aaa" "bbb" "aaa" "bbb" "ccc"
  댓글 수: 2
H.O
H.O 2024년 2월 15일
Thank you so much.
Dyuman Joshi
Dyuman Joshi 2024년 2월 15일
You're welcome!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 文字と文字列에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!