c# - Replacement group includes part of other group -


i have text:

<item>part 23 <span class='sub'>m1</span>,  <item>part 49b ; 

i want output be:

<b>part 23 </b><span class='sub'>m1</span>, <b>part 49b</b>; 

i'm using pattern: <item>(.*?)(?=<|\n|$) results in this:

<b>part 23 </b><span class='sub'>m1</span>,  <b>part 49b</b> ; 

(notice semi-colon)

if change pattern this: <item>(.*?)(<|\n|$) output this:

<b>part 23 </b>span class='sub'>m1</span>,  <b>part 49b</b>; 

(notice missing < in span>

what missing?

this seems work limited sample:

var match = @"<item>([^<\n]+)\n?"; var replace = @"<b>$1</b>";  var ans = regex.replace(src, match, replace); 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -