I have a text file that contain 3 quotations (""") in various lines in text. It also have 6 blank spaces before that in every line. I have tried doing @"\\s{6}\\"{3}"; and various cases, but it seems like c# doesn't like when it sees 3 quotations mark together. What I'm trying to do is to find that and add a new line after.
This is what i have tried:
string pattern4 = @"\s{6}"{3}";
var match4 = Regex.Match(body, pattern4, RegexOptions.Multiline);
while (match4.Success)
{
string index = """;
output.Insert(index, "\r\n");
}
Sample Input :
"""Step: 33 And I enter
Step: 34 And I set the
Desired Output:
"""
Step: 33 And I enter
Step: 34 And I set THE
To escape a quote inside a verbatim string (starts with @) use double quotes. Also there is a Regex.Replace method that you could use like this:
string input = @" """"""Step: 33 And I enter
Step: 34 And I set the ";
string pattern = @"\s{6}""{3}";
string replacement = "\"\"\"\r\n";
string output = Regex.Replace(input, pattern, replacement);
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.