[英]How to check if a string contains a substring in 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); // I used to write like this in java
我是德尔福的新手。 Delphi中是否有contains
命令或执行相同操作的任何其他命令?
您可以在Delphi中使用StrUtils
中的函数
uses
StrUtils;
..
if ContainsText('A.Sven,G.Jane,Jack', 'Jane') then
...
如果在给定文本中找到不区分大小写的子文本,则ContainsText
返回true
在StrUtils
,您还会发现StartsText
、 EndsText
和ReplaceText
等方便的函数
您可能还会发现System.SysUtils
中的Contains
函数有帮助,如下所示。
uses
Sysytem.SysUtils;
....
txt := 'This is a string variable';
if txt.contains('str') then
....
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.