How to say remove "-1" from the end of a string if exists?
    8 ビュー (過去 30 日間)
  
       古いコメントを表示
    
I have array of strings that some of them have "-1" at the end. Like "sectioned-1".
How can I get rid of "-1" from the end of thos strings?
0 件のコメント
回答 (2 件)
  Guillaume
      
      
 2020 年 1 月 29 日
        easiest way is probably with:
newarray = regexprep(yourstringarray, '-1$', '');
works with cell arrays of char vectors as well.
0 件のコメント
  Ajay Kumar
      
 2020 年 1 月 29 日
        
      編集済み: Ajay Kumar
      
 2020 年 1 月 29 日
  
      play with positions. For eg:
S = 'sectioned-1';
S = S(1:end-2)
For an array, write this in a simple for loop.
0 件のコメント
参考
カテゴリ
				Help Center および File Exchange で String Parsing についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
