lola
lola

Reputation: 5789

Ignore \n (newline characters)

I get a string which contains a sentence in two lines :

'hello this is my first.
program matlab'

and I want to change the sentence to be represend in on line:

'hello this is my first.program matlab'

How could I do it with matlab ?

Upvotes: 4

Views: 8995

Answers (1)

Andrey Rubshtein
Andrey Rubshtein

Reputation: 20915

Replace all occurrences of \n to ''

   myNewSt = strrep(mySt,sprintf('\n'),'');

For example, type:

   strrep( sprintf('this is my \n string'),sprintf('\n'),'')

Upvotes: 8

Related Questions