c# - Regex for Nested Quotes from bbcode -


i've looked on place regex work in c# can't anything. found lot php not sure on how convert on c#. i'm trying create regex recursively matches bbcode quote , changes html. here's example:

[quote="bob"]i can't believe said this: [quote="joe"]i love lamp. [/quote] that's hilarious![/quote] 

that should turn into:

<fieldset class="bbquote"><legend>bob</legend>i can't believe said  this: <fieldset class="bbquote"><legend>joe</legend>i love lamp.</fieldset>  that's hilarious!</fieldset> 

all of regex expressions have tried have failed miserably.

it not necessary recursively or match corresponding start , end of quote - @ last, same number of starts , ends must have been replaced. can accomplished nesting e. g.:

void main() {     string s = "[quote=\"bob\"]i can't believe said this: [quote=\"joe\"]i love lamp.[/quote] that's hilarious![/quote]";     regex r = new regex(@"\[quote=""(\w+)""\](.*?)\[/quote]");     while (r.match(s).success)         s = r.replace(s, "<fieldset class=\"bbquote\"><legend>$1</legend>$2</fieldset>");     console.writeline(s); } 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -