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

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 件のコメント

You can use
strtrim
function to remove the spaces between the text and then find the text.
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.
B.k Sumedha
B.k Sumedha 2015 年 12 月 5 日
Happy Coding

サインインしてコメントする。

 採用された回答

Will Kinsman
Will Kinsman 2015 年 12 月 5 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

製品

質問済み:

2015 年 12 月 5 日

回答済み:

2015 年 12 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by