javascript - Regex Lookaheads -
need capture content of root <pubdate> element, in document can either within <item> element or within <channel> element. <item> child of <channel> i'll bring example
<channel> ... <pubdate>10/2/2010</pubdate> ... <item> ... <pubdate>13/2/2029</pubdate> ... </item> ... </channel> need capture 10/2/2010
with <item> no problem, can capture it, along <pubdate>.
i don't know javascript, can't dom. agree 100% it's bad idea try , parse xml regex. there might quick, dirty, , brittle workaround, though:
if indentation consistent throughout file, , <channel> elements @ same level of indentation, use fact guide regex. in example /^ {2}<pubdate>([^<]*)<\/pubdate>/m (= 2 spaces after start-of-line) might work.
use @ own risk. here dragons etc.
Comments
Post a Comment