qq342252004 发表于 2013-5-7 09:08:29

如何取斜杠号后面的字串?(已解决)

本帖最后由 qq342252004 于 2013-5-11 18:16 编辑

D:\Program Files\Thunder Network 这个路径取斜杠号后面的字串
结果是:Thunder Network前面的D:\Program Files\不要

veket_linux 发表于 2013-5-7 09:46:10

$fullpath = "D:\Program Files\Thunder Network"
$position = StringInStr($fullpath, "\", 0, -1)
$foldername = StringMid($fullpath, $position+1)
MsgBox(0, "", $foldername)

netegg 发表于 2013-5-7 09:52:14

_WinAPI_PathFindNextComponent

veket_linux 发表于 2013-5-7 10:52:55


;_WinAPI_PathFindNextComponent会把第一个\和它前面的去掉,所以要用循环一段一段去掉
#include <WinAPIEx.au3>
$fullpath = "D:\Program Files\Thunder Network"
$buf1 = $fullpath
$buf2 = ""
While True
        $buf2 = _WinAPI_PathFindNextComponent($buf1)
        If $buf2 = "" Then ExitLoop
        $buf1 = $buf2
WEnd
MsgBox(0, "", $buf1)

afan 发表于 2013-5-7 11:14:14

Local $Str = 'D:\Program Files\Thunder Network'
MsgBox(0, StringRegExpReplace($str, '.+\\', ''), $Str)

kevinch 发表于 2013-5-7 14:53:29

$str="D:\Program Files\Thunder Network\"
$arr=StringSplit($str,"\",2)
If $arr="" Then ReDim $arr
MsgBox(0,"",$arr)这样试下

haijie1223 发表于 2013-5-7 18:57:15

回复 5# afan


    向Afan学习,思路的确独特~Dim $str="D:\Program Files\Thunder Network"
$str=StringRegExp($str,"(?:.*\\)(.*)",3)
If Not @error Then MsgBox(0,"",$str)

qq342252004 发表于 2013-5-11 18:13:06

谢谢大家,问题解决了。
页: [1]
查看完整版本: 如何取斜杠号后面的字串?(已解决)