首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

查询某个字符会合中是否有某个字符

2012-09-17 
查询某个字符集合中是否有某个字符str(F_Status,F_BillID,F_Date,F_SupplierID,F_StockTime,F_AccountDa

查询某个字符集合中是否有某个字符


str=('F_Status,F_BillID,F_Date,F_SupplierID,F_StockTime,F_AccountDate,F_SupplierName,F_Storage,')

查询str这个字符串中是否有F_BillID这个字符,不是相似,是要等于,完整的等于.



[解决办法]

Delphi(Pascal) code
function WholeMatch(AStr,AsubStr: string): boolean;var  i,j: integer;  s: string;begin  result := false;  j := Length(Asubstr);  repeat    i := pos(AsubStr,AStr);    if i = 1 then    begin      if j = Length(Astr) then      begin        result := true;        exit;      end      else if AStr[i+j+1] = ',' then      begin        result := true;        exit;      end;    end    else i > 1 then    begin      if AStr[i-1] = ',' then      begin        if i + j = Length(AStr) then        begin          result := true;          exit;        end        else if AStr[i+j+1] = ',' then        begin          result := true;          exit;        end;      end;    end    else      break;  until i < 1;end;
[解决办法]
上面错的。用这个


function WholeMatch(AStr,AsubStr: string): boolean;
var
s: string;
begin
s := AStr;
if s[1] <> ',' then
s := ','+s;
if s[Length(s)] <> ',' then
s := s+',';
result := pos(','+AsubStr+',',s) > 0;
end;
[解决办法]
if Pos('F_BillID','F_Status,F_BillID,F_Date,F_SupplierID,F_StockTime,F_AccountDate,F_SupplierName,F_Storage,') = 0 then
SHowMessage('不存在')
else
SHowMessage('存在')
[解决办法]
Delphi(Pascal) code
if Pos(','+'F_BillID'+',',','+'F_Status,F_BillID,F_Date,F_SupplierID,F_StockTime,F_AccountDate,F_SupplierName,F_Storage,') = 0 then 

热点排行