找回密码
 加入
搜索
查看: 2926|回复: 7

[AU3基础] 如何取斜杠号后面的字串?(已解决)

  [复制链接]
发表于 2013-5-7 09:08:29 | 显示全部楼层 |阅读模式
本帖最后由 qq342252004 于 2013-5-11 18:16 编辑

D:\Program Files\Thunder Network 这个路径取斜杠号后面的字串
结果是:Thunder Network前面的D:\Program Files\不要
发表于 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)
发表于 2013-5-7 09:52:14 | 显示全部楼层
_WinAPI_PathFindNextComponent

评分

参与人数 1金钱 +10 收起 理由
qq342252004 + 10 谢谢

查看全部评分

发表于 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)

评分

参与人数 1金钱 +10 收起 理由
qq342252004 + 10 谢谢

查看全部评分

发表于 2013-5-7 11:14:14 | 显示全部楼层
Local $Str = 'D:\Program Files\Thunder Network'
MsgBox(0, StringRegExpReplace($str, '.+\\', ''), $Str)

评分

参与人数 1金钱 +30 收起 理由
qq342252004 + 30 谢谢

查看全部评分

发表于 2013-5-7 14:53:29 | 显示全部楼层
$str="D:\Program Files\Thunder Network"
$arr=StringSplit($str,"",2)
If $arr[UBound($arr)-1]="" Then ReDim $arr[UBound($arr)-1]
MsgBox(0,"",$arr[UBound($arr)-1])
这样试下

评分

参与人数 1金钱 +15 收起 理由
qq342252004 + 15 谢谢

查看全部评分

发表于 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[0])

评分

参与人数 1金钱 +10 收起 理由
qq342252004 + 10 谢谢

查看全部评分

 楼主| 发表于 2013-5-11 18:13:06 | 显示全部楼层
谢谢大家,问题解决了。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-4-29 08:57 , Processed in 0.077348 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表