有没有具有这样功能的函数?
解决方案 »
- 控件YearPlanner在哪里可以下载
- FastReport 如何动态创建Barcode控件,并对条形码的属性进行设置
- 郁闷最近改进了一下藏拙分词,词库有400万词汇!5000字的文章完全切分居然需要 接近1秒钟的时间!
- for 循环中的i为何不能赋值
- record记录赋值问题
- 如何判断两个内存DC 相等
- 我打一个表格,长度不定,如何让他打完就停止,不继续走纸!急急急急急急急急!
- 大家来看 ----------------关于消息------------------------在线等
- 急急急!!寻找一函数,各位大虾帮忙啊。(一定送分)
- 请教高手:如何实现网络蚂蚁中的代理服务器的设置功能?不够再加.
- 关于Image的picture引用ImageList的图片
- 关于des加密和解密问题
var
t:tstringlist;
s:widestring;
i,j:integer;
s1:string;
p:bool;
begin
s:='asgfhj你好你好吗?';
t:=tstringlist.create;
for i:=1 to length(s) do
begin
s1:=s[i];
p:=false;
for j:=0 to t.Count-1 do
begin
if s1=t.Names[j] then
begin
p:=true;
break;
end;
end;
if p then
begin
t.Values[s1]:=Inttostr(strtoint(t.Values[s1])+1);
end else
t.Add(s1+'=1');
end;
Memo1.lines:=t;
t.Free;
end;
String str = "1212121";
System.out.println(str.split("1").length);
这里面的1就是你要搜索的字符。分割后得到数组的长度就是这个字符出现的次数。感觉还蛮方便的。
function Getchnum(Deststr:string;Findch:char):Integer;
var
Beginnum,Chnum:Integer;
begin
beginnum:=0;
chunm:=0;
while Beginnum<=Length(Deststr) do
begin
if Deststr[Beginnum]=Findch then
Inc(Chnum);
Inc(Beginnum);
end;
Result := Chnum;
end;
function GetStrNum(const SubStr, S: string): Integer;
var
I: Integer;
begin
Result := 0;
I := PosEx(SubStr, S, 1);
if I > 0 then
Inc(Result)
else
Exit; while (I > 0) and (I < Length(S)) do
begin
I := PosEx(SubStr, S, I + 1);
if I > 0 then
Inc(Result);
end;
end;ShwMessage(IntToStr(GetStrNum('12', '12312')));支持子字符串在另外个字符串中出现的次数
uses
StrUtils;
没有,有定位第一次出现的函数pos
function SubStrConut(mStr, mSub: string): Integer; //返回mSub字符串在mStr字符串中的个数
begin
Result := (Length(mStr) - Length(StringReplace(mStr,mSub,'',[rfReplaceAll])))
div Length(mSub);
end;
begin
if str[i]=c then count++
end;
此法比较快如果觉得还慢 那就汇编吧