Was*_*RAR -1 java regex indexing substring
我有这种格式的字符串:
file://c:/Users/....
file://E:/Windows/....
file:///f:/temp/....
file:///H:/something/....
Run Code Online (Sandbox Code Playgroud)
我怎么才能得到c:/Users/...
或H:/something/...
?
经过测试并将替换任意数量的斜杠.
String path = yourString.replaceFirst("file:/*", "");
Run Code Online (Sandbox Code Playgroud)
如果你只想要它匹配两个或三个斜杠
String path = yourString.replaceFirst("file:/{2,3}", "");
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
227 次 |
最近记录: |