How do I search for a string in a text file that has carriage returns within the string

4 次查看(过去 30 天)
I have a text file I am trying to locate strings. Lets say that the txt file looked like this:
'hello
world'
When I search for the string 'hello world' the above txt file would yield 0 results. How can I go about getting a result for this instead of it being overlooked?
Thank you for the help. Will
  3 个评论
Will Kinsman
Will Kinsman 2015-12-5
Excellent. Similarly I also found I could use
str = regexprep(str,'\r\n|\n|\r',' ')
to remove formatting from my primary string and then search for the string.

请先登录,再进行评论。

采纳的回答

Will Kinsman
Will Kinsman 2015-12-5
str = regexprep(str,'\r\n|\n|\r',' ') or strtrim to remove formatting from the string and THEN doing a string search solves this issue

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by