How to replace new line with white space in text documents

34 vues (au cours des 30 derniers jours)
Fateme Jalali
Fateme Jalali le 31 Jan 2016
Commenté : Andrew Mohan le 17 Jan 2018
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', ' '))

Réponse acceptée

Stephen23
Stephen23 le 31 Jan 2016
Modifié(e) : Stephen23 le 31 Jan 2016
str = regexprep(test1,'\s+',' ');
or
str = regexprep(test1,'[\n\r]+',' ')
  2 commentaires
Fateme Jalali
Fateme Jalali le 31 Jan 2016
thank u
Andrew Mohan
Andrew Mohan le 17 Jan 2018
This does the trick. Thanks.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Dialog Boxes dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by