About 2,120 results
Open links in new tab
  1. c# - Regular Expression replace specific characters - Code Review Stack ...

    Does anyone know of a better / cleaner way to write the following: GetSafeTagName(txtUserInput.text); public static string GetSafeTagName(string tag) { tag = tag ...

  2. c# - Regex to first match, then replace found matches - Code Review ...

    Feb 11, 2016 · toSearchInside = regex.Replace(toSearchInside, replacement); } And I can get this working, but it seems somewhat inefficient in that it is using the regex engine twice - Once to find the …

  3. c# - Best way to replace Urls in .Net application - Code Review Stack ...

    Mar 28, 2020 · The Regex.Replace method internally executes the Regex.Match method before replacing any text, therefore it is unnecessary to use the if statement.

  4. c# - Replace each whitespace in a string with "%20" - Code Review …

    public static string ReplaceAllSpaces(string str) { return Regex.Replace(str, @"\s+","%20"); } The expression \s+ consists of the pattern \s that matches a whitespace character (which is more that just …

  5. c# - How to replace the given email address with a value in a given ...

    May 1, 2021 · I'm wondering why you use c# if you can't even use basic c#/.net functions? If you want to use the basic programming languages like c/c++ I'd suggest to provide it with c instead the lowest …

  6. c# - Replacing from a list chars in a string - Code Review Stack Exchange

    Feb 22, 2013 · @Leonid Path.GetInvalidPathChars () returns a char[] of characters that are illegal in a file name. What I wanted to know is what is the proper way to clean a filename from the returned …

  7. c# - Replace all the occurrence of a string - Code Review Stack Exchange

    Jul 12, 2018 · 10 Loops can sometimes be so ugly. You can get rid of them completely and use Regex instead. It'll replace the placeholders one by one without scanning the string from the beginning each …

  8. c# - regex string extension - Code Review Stack Exchange

    Here's another small experiment with C# 7 where you could use anonymous tuples with only one method. But actually you could return a tuple in you current solution too. public static class …

  9. c# - Multiple string replacement (with similarity) using a dictionary ...

    Dec 20, 2018 · I'm trying to replace a number of keywords with other corresponding values. I started with this method: Dictionary<string, string> keywords = GetKeywords(); foreach (var pair in …

  10. c# - Replacing non-ASCII characters - Code Review Stack Exchange

    Aug 5, 2014 · I wrote a C# program to remove non-ASCII characters in a text file, and then output the result to a .NonAsciiChars file. The input file is in XML format. In fact, the data may all be on two lines,...