判斷乙個字串是否是時間表示式 DELPHI

2021-06-07 18:53:00 字數 993 閱讀 1831

function istime(astring: string; adelimiter: char): boolean; 

function isvalid(s: string; i: integer): boolean;

begin

case i of

1: result := strtoint(s) in [0..24];

2, 3: result := strtoint(s) in [0..59];

else

result := false;

end; //end case

end;

var

p, start: pchar;

str: string;

count: integer;

begin

result := false;

//嘿嘿,最大長度和最小長度的區別。按照549的題意字串長度一定在6~9

if (not (length(astring) in [6..8])) or (astring = '') then exit;

p := pointer(astring);

count := 1;

while (p^ <> #0) do

begin

if (count > 3) then exit;

start := p;

while not (p^ in [#0, adelimiter]) do inc(p);

setstring(str, start, p - start);

if (not isvalid(str, count)) then exit;

if (p^ = adelimiter) then inc(p);

inc(count);

end;

result := true;

end;

判斷乙個字串是否是另乙個字串的子集

案例 c 開發 遇到模糊查詢的功能實現,不是直接查詢資料庫,而是匹配另外一些本地資料。string a asd string b asdsdad 其實a b的值都是取得動態資料。一開始自己寫了乙個函式用來判斷a是否在b中,for 迴圈即可。後來,才知道.net平台有這樣的函式,判斷字串的子集的索引號...

SQL 判斷乙個字串是否在另外乙個字串中

eg str1 admin str2 1234,123admin,xcxx 比較str1是否在str2中 用常用的charindex,返回肯定是有值的,這裡自己動手寫乙個方法 檢查乙個字串是否在另外乙個字串中數,另外乙個字串元素用,隔開 create function dbo checkstrina...

python判斷乙個字串是否是小數

最近在寫 的時候,發現乙個問題,想判斷乙個字串是不是乙個合法的小數,發現字串沒有內建判斷小數的方法,然後就寫了乙個判斷字串是否是小數,可以判斷正負小數,如下 12 3456 78910 1112 1314 1516 def is float s s str s ifs.count 1 判斷小數點個數...