字符串取值问题(100)

  • 主题发起人 狼崖山
  • 开始时间

狼崖山

Unregistered / Unconfirmed
GUEST, unregistred user!
如何取到固定格式的值啊? 如:http://192.194.158.222/wjj/ 取到值 http://192.194.158.222/http://192.168.3.34/wjj/ 取到值 http://192.168.3.34/
 
很久不搞开发了
 
很久不搞开发了
 
可以用 format 来进行格式化。。
 
pos定位右边位置copy拷贝给你个参考//提取字符串function SubString(aInputStr, aStr_L, aStr_R: widestring): string;var sPosB, sPosE: integer; Lwhtml, LwCstr_L, LwCstr_R: string;begin Result := ''; if Trim(aInputStr) = '' then Exit; Lwhtml := LowerCase(aInputStr); LwCstr_L := LowerCase(aStr_L); LwCstr_R := LowerCase(aStr_R); sPosB := Pos(LwCstr_L, Lwhtml) + Length(LwCstr_L); sPosE := PosEx(LwCstr_R, Lwhtml, sPosB); if (sPosB < sPosE) and (sPosE > 0) then Result := Copy(aInputStr, sPosB, sPosE - sPosB);end;
 
有没有其他的方法啊?PosEx()在那个单元的啊?
 
uses StrUtils;function FormatURL(const AURL: String): String;var i: Integer; sURL: String;begin sURL := Trim(AURL); i := PosEx('/',sURL,Length('http://') + 1); if i <=0 then Exit; Result := Copy(sURL,1,i);end;
 
uses StrUtils;varS,t,f: string;p :integer;beginS := 'http://10.194.158.221/FuJian/';p:=pos('n/',S);f:=copy(S,1,p-7);//f:=LeftStr(s, 7);ShowMessage(f);end;
 
谢谢。。。没想到土方法也行
 

Similar threads

S
回复
0
查看
451
swish
S
回复
0
查看
858
不得闲
回复
0
查看
670
不得闲
回复
0
查看
817
不得闲
顶部