javascript - Problem with regexp in userscript for chrome -


this might noob question, have tried find answere here , on other sites , have still not find answere. @ least not understand enough fix problem.

this used in userscript chrome.

i'm trying select date string. string innerhtml tag have managed select. html structure, , string, this: (the div selected tag within content of string)

<div id="the_selected_tag">       <a href="http://www.something.com"  title="something xxx">link</a>       " 2011-02-18 23:02"       <a href="http://www.somthingelse.com" title="another link">thing</a> </div> 

if have solution helps me select date without fuzz, great.

the javascript:

var pattern = /\"\s[\d\s:-]*\"/i; var tag = document.queryselector('div.the_selected_tag'); var date_str = tag.innerhtml.match(pattern)[0] 

when use script ordinary javascript on html document test it, works perfectly, when install userscript in chrome, doesn't find pattern.

i can't figure out how around problem.

dump innerhtml console. if looks fine start building regexp more generic (/\d+/) more specific ones , output console. there bunch of different quote characters in different encodings, many different types of dashes.

[\d\s:-]* not choice because match " 1", " ". rather write specific possible:

/" \d{4}-\d{2}-\d{2} \d{2}:\d{2}"/ 

(also document.queryselector('div.the_selected_tag') return null on sample wanted write class instead of id)


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -