我的输出基本上是一个段落,当我尝试在字符串中搜索子字符串时,如果该子字符串被分割,它就不起作用。如何使段落字符串只有 1 行?
示例字符串:
I have an output that is basically a paragraph and when I try
to search the string for a substring, if that substring is split up it
doesn't work. How can I make the paragraph string into just 1 line?
子字符串:“它不起作用”
当我尝试搜索该子字符串时,它不会返回 true。
看来您想将换行符视为空格。编写高效的搜索算法并非易事,而是一种可以works并回答你标题中的问题是
str := StringReplace(str, sLineBreak, ' ', [rfReplaceAll]);
也就是说,我们只需用空格替换所有换行符即可。没有魔法常数,这是
str := StringReplace(str, #13#10, #32, [rfReplaceAll]);
也许除了换行符之外,单词之间已经有空格了?然后只需删除换行符,而不添加空格:
str := StringReplace(str, #13#10, '', [rfReplaceAll]);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)