MATLAB: Finding carriage returns (i.e. \n) in a text file

\ncarriage return

Hi all, I have a text file with carriage returns in it, and am trying to test if an index is a carriage return but have been unsuccessful. For simplicity, lets say that the text file only uses \r as a carriage return. I understand that isstrprop(text(index),'wspace') can identify if it is a space OR a carriage return, but I want to check only to see if it is a carriage return.
Any advice? Let me know if I can be any clearer here.
Thank you so much in advance, William

Best Answer

See if this does what you want:
Q = sprintf('This is a string \r with a newline character.\r');
NL = regexp(Q, '[\r]');
The ‘NL’ variable contains the indices of the occurrences of '\r' in the string.