-5

I have a string like this: first/exemple/import/status/5b12f918-f2ef-436f-808c-50ea48da000
I need to the output like this: first/exemple/import/

I need to remove from status and so on. I thought about remplace but it wont work because this 5b12f918-f2ef-436f-808c-50ea48da000 is variable so it changes. if there any function can do this please

Sacamoto
  • 107
  • 1
  • 8

1 Answers1

1

If you can guarantee the structure of the text (ie that structure won't change):

public static ReturnFirst(string inString){
     var path = inString.Split('//')[1];
     return $"//{path}//";
}

Or read the first 'x' characters of the string

Jonathan
  • 4,916
  • 2
  • 20
  • 37
  • thanks @jonathan for your answer, I have changed the exemple, it wont work in this solution – Sacamoto Oct 07 '20 at 16:18
  • 1
    You added additional values into the array before 'import'. So now you'll have to take more than just the first entry in the array... – Jonathan Oct 07 '20 at 16:21