I have a HTML-String and want to get the inner html of all tr’s inside. In past I have used jQuery to do it in JavaScript, but I’m using Appcelerator now, and it is not possible to use DOM there.
I have a regex that works for php, but I don’t know how to use it in JS.
Does anyone know how to use this regex in JS or has an other solution.
php regex:
preg_match_all("#\<tr\>(.+?)\<\/tr\>#s", $html, $match);
I’d do something like this (untested):
Note the use of
[^>]*and similar:This is like saying “match 0 or more of anything that’s not ‘>’ ” and is much faster than comparing to every single character ‘.’ can represent until a match is established. The only reason to use the ‘.’ wildcard in regEx is to find the really old obscure whitespace characters that it doesn’t represent. That could actually make a pretty huge difference for dumb browser regEx engines handling large tables.