Good evening.
How can I convert the following string: "image / jpg, image / jpeg, application / pdf" in the following: ".jpg, .pdf, .zip"
Also taking into account that the first chain can include more extensions.
Thank you.
Good evening.
How can I convert the following string: "image / jpg, image / jpeg, application / pdf" in the following: ".jpg, .pdf, .zip"
Also taking into account that the first chain can include more extensions.
Thank you.
You can use regular expressions:
var cadena = "image/jpg,image/jpeg,application/pdf";
// Obtenemos las extensiones
var result = Regex.Matches(cadena, @"\w+/(\w+)")
.Cast<Match>().Select(x => $".{x.Groups[1].Value}");
// Concatena las extensiones utilizando la , como separador
Console.WriteLine(string.Join(",", result));