Modify text in a column
    4 ビュー (過去 30 日間)
  
       古いコメントを表示
    
Dear all, I want to modify just the first column of a file, removing the letters and keeping the numbers. The columns contain string like d200n-h. How it is possible?
Thanks,
Marco
0 件のコメント
回答 (1 件)
  Walter Roberson
      
      
 2019 年 6 月 26 日
        
      編集済み: Walter Roberson
      
      
 2019 年 6 月 26 日
  
      Assuming comma delimited:
S = fileread('YourFile.txt');
newS = regexprep(S, '^\D*(\d+)[^,]+(,.*$)', '$1$2', 'lineanchors', 'dotexceptnewline');
fid = fopen('YourNewFile.txt');
fwrite(fid, newS);
fclose(fid)
This should work even if there is "" around the string, but it will remove the "" if present.
参考
カテゴリ
				Help Center および File Exchange で Creating, Deleting, and Querying Graphics Objects についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

