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 

demo

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(); 

ideone


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -