一个简单的语句问题

sharewarer 2003-08-24 03:30:39
匹配一句话的其中一段字符的语句如何写呢?
如匹配filter中的“il”
如匹配“中国人”中的“国”...
...全文
38 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ly840325 2003-08-25
  • 打赏
  • 举报
回复
学习呀~~
xuejinlong 2003-08-25
  • 打赏
  • 举报
回复
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
nature 2003-08-24
  • 打赏
  • 举报
回复
你要sql语句还是pascal?
sql:select * from table1 where aa like '%il%'

pascl:pos('il','fielter')>0
sharewarer 2003-08-24
  • 打赏
  • 举报
回复
if trim(edit5.Text)<>'' then
filterstr:=filterstr+' and '+' pos(1,a)>0';

这句代码为何是错的?
sharewarer 2003-08-24
  • 打赏
  • 举报
回复
我的帮助里好像没有pos,给粘贴一下行吗?
sharewarer 2003-08-24
  • 打赏
  • 举报
回复
实际情况时,被查询字段可能是edit1.text,请给出代码
xuejinlong 2003-08-24
  • 打赏
  • 举报
回复
用Pos函数,看一下帮助就明白了。
sharewarer 2003-08-24
  • 打赏
  • 举报
回复
huojiehai(海天子)

我是想用filter,但你的代码对吗?我调试好像有问题?
cnhgj 2003-08-24
  • 打赏
  • 举报
回复
字符串操作用一楼兄,数据库查询用二、三楼兄
wyr521 2003-08-24
  • 打赏
  • 举报
回复
select * from table
where 字段名 like '%国%'
karach 2003-08-24
  • 打赏
  • 举报
回复
select * from table
where 字段名 like '%国%'
huojiehai 2003-08-24
  • 打赏
  • 举报
回复
str := 'filter';
if pos('il', str) > 0 then
showmessage('找到');

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧