Hello, I'm trying to select a word and around the 200 characters of it from a web page, and send it to my local server via a bookmarklet. but something is not working, and giving me a null. here's my test code(for firefox) javascript:var tx=document.body.innerHTML;var tx=tx.replace(/<[^>]*>/g,"");var wd=document.getSelection();var reg=new RegExp('.{100}' + wd + '.{100}');var sen=tx.match(reg);alert(sen); Code (markup): when I try this code, say at this website. http://en.wikipedia.org/wiki/Cartman%27s_Mom_Is_a_Dirty_Slut words like 'episode' and 'Learning' giving me a null but when I select 'father' or 'apparent' and click the bookmarklet, it works fine. I'm wondering what causes this problem. Could someone tell me what is wrong with my code? Any help would be appreciated. thanks. P.S. here's plain match version; javascript:var tx=document.body.innerHTML;var tx=tx.replace(/<[^>]*>/g,"");var sen=tx.match(/.{10}episode.{10}/);alert(sen); Code (markup): This code works with any word(in this code 'episode') in a web page. But you have to change the reqular expression manually, and that is not an option.
I fix that. here's my latest test code(firefox) javascript:var tx=document.body.innerHTML;tx=tx.replace(/<.+?>/g,"");tx=tx.replace(/\n/g," ");var wd=document.getSelection();var reg=new RegExp('.{100}' + wd + '.{100}');var sen=tx.match(reg);alert(sen[0]); Code (markup): This works fine. I think I solved the problem. I'm sure there are some redundancy, but it'll do. If you have any suggestions, feel free to let me know. thanks!