如何在Delphi中检查字符串是否包含子字符串? [英] How to check if a string contains a substring in Delphi?
本文介绍了如何在Delphi中检查字符串是否包含子字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
String content = "Jane";
String container = 'A.Sven,G.Jane,Jack'; // This is the string which i need to be searched with string content
进行搜索的字符串boolean containerContainsContent = StringUtils.containsIgnoreCase(container,content); //我以前是在java
这样写的,我是 Delphi 的新手。在 Delphi 中是否存在个包含
的命令或执行相同操作的任何其他命令?
I am new to Delphi. Is there a contains
command in Delphi or any other command which performs the same operation?
推荐答案
您可以在 Delphi的 StrUtils
中使用函数
You can use the functions in StrUtils
in Delphi
uses
StrUtils;
..
if ContainsText('A.Sven,G.Jane,Jack', 'Jane') then
...
ContainsText
如果找到子文本,则返回 true
,不区分大小写,在给定的文本中
ContainsText
returns true
if the subtext is found, without case-sensitivity, in the given text
在 StrUtils
中,您还会发现方便的函数,例如 StartsText
, EndsText
和 ReplaceText
In StrUtils
you'll also find handy functions like StartsText
, EndsText
and ReplaceText
这篇关于如何在Delphi中检查字符串是否包含子字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文