Reputation: 5789
I get the value of output, which corresponds to the diff between 2 files :
output = 'a.x: low 0 -> low 1a.b : 3 -> Medium 6'
then I printf
the content
sprintf('files are different \n%s', output);
but I would like to show it as follows (word wrap):
output :
a.x: low 0 -> low 1
a.b : 3 -> Medium 6
Upvotes: 2
Views: 1052
Reputation: 6591
You could use a regular expression to chop your string
chopped = regexpi(output, '^(?<line1>[^>]*>[^\d]*[\d]*)(?<line2>.*)$', 'names')
does the trick here.
>> chopped =
line1: 'a.x: low 0 -> low 1'
line2: 'a.b : 3 -> Medium 6'
The assumptions are:
->
in the first line->
If you're not familiar with regex
(?<line1> )
and (?<line2> )
are here to capture the matches in the chopped
variable.[^>]*
consumes until first >
[^\d]*
consumes all non numerical characters (so until the following number starts)[\d]*
consumes all numerical characters.*
consumes rest of the stringUpvotes: 1