I have a tons of strings and values like "test la'la'la'la'la".
I need to find all ' indexes and insert another ' to string. => "test la''la''la''la''la"
Because of PostgreSQL.
How to do it more effectionaly? I have a list of thousands strings like this, so i need make it as faster as possible.
Maybe need use LINQ?
How about a simple Select()
and Replace()
;
[Test]
public void Replace_in_strings_works()
{
var strings = new List<string>
{
"one'two'three'",
"four'five'six'",
};
var transformedStrings = strings.Select(x => x.Replace("'", "''")).ToList();
transformedStrings.ForEach(Console.WriteLine);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.