Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可以说我有以下路径:
path = "/v4r/www/what3ver/te5t1ng"
我想在最后一个斜杠“/”之后捕获所有出现的 \d。所以在这种情况下,我想得到 ["5","1"]
我如何使用单个正则表达式来做到这一点?
您可以使用前瞻断言在您捕获的数字之后只有非斜杠字符:
\d(?=[^\/]*$)