简体   繁体   中英

regex - deleting part of url

How can I delete with regex from URL (string) http://test.com/org/category,1/2 , this part:
/2 or /2/ , with C# language

Of course, there will be numbers like category,1/412/ , category,1/521 , category,1/infinity..

How can I do this with regex?

It seems that you want to replace /\\d+/?$ with empty string.

You could do that with:

url = Regex.Replace(url, @"/\d+/?$", "");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM