您的位置:程序门 -> vb -> 基础类



求在vb中判断文件路径(如c:\windows\test.exe的样式)的正则表达式


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


求在vb中判断文件路径(如c:\windows\test.exe的样式)的正则表达式
发表于:2007-09-25 13:18:41 楼主
求在vb中判断文件路径(如c:\windows\test.exe的样式)的正则表达式


请写全部过程谢谢
发表于:2007-09-26 18:55:591楼 得分:0
public   function   getfilenameofpath(path   as   string)

on   error   goto   proc_err:

        dim   i   as   integer,   arraylen   as   integer,   temp   as   integer
       
        arraylen   =   len(path)
        for   i   =   arraylen   to   1   step   -1
                if   mid(path,   i,   1)   =   "\ "   then
                        temp   =   i
                        exit   for
                end   if
        next   i
               
        if   arraylen   <=   3   then
                getfilenameofpath   =   " "
        else
                getfilenameofpath   =   right(path,   (arraylen   -   temp))
        end   if
       
proc_exit:
        exit   function

proc_err:
        goto   proc_exit
       
end   function
发表于:2007-09-28 11:01:312楼 得分:0
有函数啊
fileexists(filename)
发表于:2007-09-29 14:31:323楼 得分:0
用dir函数:   dir(path)   如果path存在,则返回正确路径,否则返回空.
发表于:2007-09-29 14:42:124楼 得分:0
你是要验证输入是否正确?还是......?
发表于:2007-09-29 14:48:135楼 得分:0
'引用   microsoft   vbscript   regular   expressions

function   b(s   as   string,   p   as   string)   as   boolean
       
on   error   goto   100
       
        dim   myreg   as   regexp
        set   myreg   =   new   regexp
        myreg.ignorecase   =   true
        myreg.pattern   =   p
        b   =   myreg.test(s)
        exit   function
100:
        b   =   false
end   function

'调用:
        dim   p   as   string
        p   =   "^[a-za-z]:(\\[^\\/:"""" <> \ ¦]+)+$"
        msgbox   b(c:\windows\test.exe,   p)
发表于:2007-09-29 14:49:576楼 得分:0
sorry:纠正一下:

'调用:  
        dim   p   as   string  
        p   =   "^[a-za-z]:(\\[^\\/:""""   <   > \   |]+)+$"  
        msgbox   b("c:\windows\test.exe",   p)


快速检索

最新资讯
热门点击