c# - Start a new line after a multiple character group with Regex -
i'd create new line right after character group detected. group consists of 2 or more star characters in given text. reg-ex knowledge low, please out this.
i tried coding below fails want accomplish. puts new line after each star, should done 2 or more stars.
string result = "*1, **1, **1, ***1, *2, **2, *2, *2, **3, *3"; console.writeline(regex.replace(result, @"[*(\\*\\*)+]", "\r\n$0"));
result should formatted below; when there's 2 or more starts together, start new line;
*1, **1, **1, ***1, *2, **2, *2, *2 **3, *3
regex:
\s*(\*\*)
replacement string:
\n$1
c# code be,
string str = "*1, **1, **1, ***1, *2, **2, *2, *2, **3, *3"; string result = regex.replace(str, @"\s*(\*\*)", "\n$1"); console.writeline(result); console.readline();
Comments
Post a Comment