Remove text from string until it reaches a certain character

后端 未结 4 2029
忘掉有多难
忘掉有多难 2021-01-17 12:26

I\'m having a issue trying to figure out this. I need to \"fix\" some links, here is an example:

  1. www.site.com/link/index.php?REMOVETHISHERE
  2. www.site.c
4条回答
  •  有刺的猬
    2021-01-17 12:49

     string s = @"www.site.com/link/index.php?REMOVETHISHERE";
     s = s.Remove( s.LastIndexOf('?') );
     //Now s will be simply "www.site.com/link/index.php"
    

    should do it

提交回复
热议问题