フィルターのクリア

How to replace new line with white space in text documents

24 ビュー (過去 30 日間)
Fateme Jalali
Fateme Jalali 2016 年 1 月 31 日
コメント済み: Andrew Mohan 2018 年 1 月 17 日
Hello,I am trying to change all new lines in my database with white space,but codes does not work.can any one help me please.Data base is attached.
test1 = fileread('part1.txt');
newTest = sprintf(strrep(test1, '\n', ' '))

採用された回答

Stephen23
Stephen23 2016 年 1 月 31 日
編集済み: Stephen23 2016 年 1 月 31 日
str = regexprep(test1,'\s+',' ');
or
str = regexprep(test1,'[\n\r]+',' ')
  2 件のコメント
Fateme Jalali
Fateme Jalali 2016 年 1 月 31 日
thank u
Andrew Mohan
Andrew Mohan 2018 年 1 月 17 日
This does the trick. Thanks.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDatabase Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by