0

I have one string like:

Sonographie Schilddrüse:1
Sonographie Gynäkologie:1
Fragestellung: Zust. nach TEP
evt- Infotyp: FRAGE
Kennzeichen OBX-Segment
HL7: FRAGE
Mobilität: FG; Pat. Fußgänger
Transportart: GEH; gehfähig
Schwangerschaft: 0 Patient nüchtern: 0

and would like to remove FG; and GEH;

Is it possible to remove the characters between the symbols : and ; in a string? Can anyone tell me how in C#?

Thanks in advance!

huMpty duMpty
  • 14,346
  • 14
  • 60
  • 99
lerx
  • 11
  • 3
  • 1
    Did you check [String.IndexOf](https://learn.microsoft.com/en-us/dotnet/api/system.string.indexof?view=netframework-4.7.2) and [String.Substring](https://learn.microsoft.com/en-us/dotnet/api/system.string.substring?view=netframework-4.7.2) – huMpty duMpty Feb 27 '19 at 09:16
  • 1
    `string result = Regex.Repace(myString, @":\s*[A-Z]+;", " ");` – Dmitry Bychenko Feb 27 '19 at 09:16
  • This is a duplicate of https://stackoverflow.com/questions/20701818/how-to-replace-the-text-between-two-characters-in-c-sharp – Tiago Silva Feb 27 '19 at 09:17

1 Answers1

0

Would go for regex replace:

    static void Main(string[] args)
    {
        var inputString = "Mobilität: FG; Pat. Fußgänger";
        var outputString = Regex.Replace(inputString, ":.+;", ":");
        Console.WriteLine(outputString); 
    }
Serban Murariu
  • 107
  • 1
  • 11