一个简单的语句问题
匹配一句话的其中一段字符的语句如何写呢?
如匹配filter中的“il”
如匹配“中国人”中的“国”...
推荐阅读
str := filter;
if pos(il, str) > 0 then
showmessage(找到);
select * from table
where 字段名 like %国%
字符串操作用一楼兄,数据库查询用二、三楼兄
用pos函数,看一下帮助就明白了。
你要sql语句还是pascal?
sql:select * from table1 where aa like %il%
pascl:pos(il,fielter)>0
returns the index value of the first character in a specified substring that occurs in a given string.
unit
system
category
string handling routines
delphi syntax:
function pos(substr: string; s: string): integer;
description
in delphi, pos searches for a substring, substr, in a string, s. substr and s are string-type expressions.
pos searches for substr within s and returns an integer value that is the index of the first character of substr within s. pos is case-sensitive. if substr is not found, pos returns zero.
the posex function is similar to pos, but provides additional features and can be used in c++ code.
-------------------------------------------------------------------------
如果要在edit1.text里面查询“中国”两个字符,则:
pos(中国,edit1.text);
如果查到,返回值是“中国”在edit1.text中第一次出现的位置,如果没查到,返回0


讨论区