KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
public class Abbreviation { public string ShortName { get; set; } public string LongName { get; set; } } I have a list of Abbreviation objects like this: List abbreviations = new List(); abbreviations.add(new Abbreviation() {ShortName = "exp.", LongName = "expression"}); abbreviations.add(new Abbreviation() {ShortName = "para.", LongName = "paragraph"}); abbreviations.add(new Abbreviation() {ShortName = "ans.", LongName = "answer"}); string test = "this is a test exp. in a para. contains ans. for a question"; string result = test.Replace("exp.", "expression") ... I expect the result to be: "this is a test expression in a paragraph contains answer for a question" Currently I am doing: foreach (Abbreviation abbreviation in abbreviations) { test = test.Replace(abbreviation.ShortName, abbreviation.LongName); } result = test; Wondering if there is a better way using a combination of Linq and Regex.
Tags (comma-separated)
Save Edits
Cancel