【发布时间】:2020-09-22 05:43:00
【问题描述】:
我正在尝试提取 '/' 和 '.' 之间的字符串的一条路径。例如,我有一个类似“/com/testproj/part1/string.html”的路径。我需要从这个路径中提取“part1”,“/com/testproject/”总是固定的。我还有其他路径,例如 /com/testproj/part2/string.html、/com/testproj/part3/string.html。
-
例如
-
/com/testproj/part1/dfb/rgf/string.html - part1
-
/com/testproj/part126/dfb/rgf/string.html-part126
-
/com/testproj/part45/dfb/rgf/string.html - part45
【问题讨论】:
-
你说你想提取'/'和'.'之间的字符串。的路径,对于
"/com/testproj/part1/string.html"将是part1/string,但你说你只想要part1。是哪个? -
@Bohemian 请找到一些路径示例.. /com/testproj/part1/dfb/rgf/string.html, /com/testproj/part2/dfb/rgf/string.html, /com /testproj/part3/dfb/rgf/string.html, /com/testproj/part4/dfb/rgf/string.html, /com/testproj/part14545/dfb/rgf/string.html .. 对于每个路径我需要提取路径及其编号..
-
您要搜索的文本是否总是文字
part后跟一些数字? -
来自
/com/testproj/part4/dfb/rgf/string.html你需要part4还是part4/dfg/rgf? -
从您的示例中,仅第 4 部分,添加了一些有问题的示例..