LZY'Blog

记录LZY的生活、行程!

« 取得字符串以特定字符sub间隔的个数Progress中的entry函数说明及演示示例 »

指定某特定字符为间隔的第几串字符

/* 指定某特定字符为间隔的第几串字符 */
function GetChar returns char (input s as char, input sub as char, input num as integer).
    define variable s1 as char.
    define variable s2 as char.
    define variable l as integer.
    define variable i as integer.
    define variable fori as integer.

    l = length(s).
    s2 = "".
    fori = 0.
    do i = 1 to l:
        s1 = substring(s,i,1).
        if s1 <> sub then
            s2 = s2 + s1.
        else do:
            fori = fori + 1.
            if fori = num then do:
                return s2.
                leave.
            end.
            else do:
                s2 = "".
            end.
        end.
        if i = 1 and s1 <> sub and num = fori + 1 then return s2.
    end.
    return s2.
end function.

/* GetChar调用示例 */
display GetChar("longziyong.cn","o",3).   /* 输出结果:ng.cn */
  • quote 1.KOSS
  • 你可以使用progress自带的函数来达到这个功能。
    disp entry(3,"longziyong.cn","o") .
    longziyong 于 2018/10/3 13:33:33 回复
    多谢指教
  • 2018/10/3 12:31:49 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Walle Build 100427 |

Copyright 2009-2012 LZY'Blog. | ICP:蜀ICP备05027543号