I have data stored using tinymce with placeholders before each table
Editor view when data is entered:
#data1
[html table1]
#data2
[html table2]
#data3
[html table3]
this is stored in database wrapped with <p> tag in database.
I want to strip and get html table based on parameter passed.
string getTable(string placeholder)
{
string content = db.getData();
//placeholder = data1, return html table 1 substring data from content variable
return [html table1]; //html string
//placeholder = data2
return [html table2]; //html string
}
How can i achieve this using C#?
I think this regex might be reliable
#data2([^#]+|#(?!data))+</table>(click to see the example), but it depends on your input, it can break. You can’t trust regex to parse html.To match the table by its ID you could try
<table.*?id=.t1.>([^<]|\<(?!/table))+</table>.