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.
如何使用正则表达式查找 url 部分?
网址:/text1/text2/text3-text4-text5-text6-text7/aaa/100
我怎么能找到aaa???
var uri = new Uri(s); return uri.Segments[uri.Segments.Length-2];
或者
new Uri(s).Segments.Where(x => x == "aaa");
new Uri(s).Segments.Where(x => Regex.IsMatch(x, "^a+$");
...
你的问题对于你真正想要什么以及目的是什么相当模糊。