php - Change all table tags with preg_match_all -
i alter tag in string set [table1], [table2], etc.
for example,
hello there <table class="table1"><tr><td></td></tr></table> text here <table class="table2"><tr><td></td></tr></table> text here <table class="table3"><tr><td></td></tr></table>
to:
hello there [table1] text here [table2] text here [table3]
using
preg_match_all("@\<table (\s\s+)@s", $table_in_string, $match); foreach ($match[1] $key => $k) { }
my regular look here not seem work.
thanks.
pregl_replace example:
$text = preg_replace( '/<table.*?class="(table\d+)".*?<\/table>/s', '[$1]', $text );
php regex preg-match preg-match-all
No comments:
Post a Comment