【发布时间】:2016-06-04 03:33:43
【问题描述】:
我有一个目录列表:
/media/nosthertus/music/oor no scared.mp3
/media/nosthertus/OST/data/music/zone4_1.ogg
/media/nosthertus/OST/data/music/zone4_2.ogg
/media/nosthertus/music/Epic Hybrid _ Alex Moukala - Reborn _ Orchestral Action Rock _ EpicMusicVN.mp3
我不太擅长REGEX,所以我尝试使用这个表达式:
/\/(\w+|(\w+\s))\..{3}/g
有一个regex101 会话有更多关于我尝试匹配here 中的目录的示例
请解释我做错了什么..
编辑:我想匹配包含在字符串中的整个目录..例如
Some random string text here
/dir/to/folder/or/file.ext //Match this whole DIR
【问题讨论】:
-
你想匹配什么?你想要什么输出?
-
@rock321987 我已经编辑了问题
-
你能澄清一下你想在
/media/nosthertus/OST/data/music/zone4_2.ogg中匹配什么吗? -
@rock321987 我想匹配所有内容,你可以在 regex101 中看到其他不是目录的东西,我的目标是在一个 javascript 函数中使用它,该函数将从字符串中提取所有目录
-
this好吗?
标签: regex