Skip to content

Instantly share code, notes, and snippets.

@MerlinTwi
Created March 12, 2018 06:59
Show Gist options
  • Select an option

  • Save MerlinTwi/c25cbd3a6adf9b9b8db57c4dbfb5c505 to your computer and use it in GitHub Desktop.

Select an option

Save MerlinTwi/c25cbd3a6adf9b9b8db57c4dbfb5c505 to your computer and use it in GitHub Desktop.
Replace quotes ".." to pair «..»
public static string ReplaceQuotes(string s) {
var quotes = new[] { "«", "»" };
int n = 0;
while (true) {
int i = s.IndexOf("\"", StringComparison.Ordinal);
if (i < 0) break;
s = s.Substring(0, i) + quotes[n++%quotes.Length] + s.Substring(i + 1);
}
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment