Biks 9 Posted October 2, 2010 Report Share Posted October 2, 2010 I created a ubot that scrapes keywords out of the latest Google keyword tool. Sometimes a scraped word will be in bold and I want to get rid of the <B> and </B> tags with one javascript .replace expression. Right now I'm doing it with two: http://img62.imageshack.us/img62/9205/strip.png It works, but how do I simplify it so I have the eval only running once. I'm sure you can do it, I just don't know the syntax to combine two choices. Something like this? '{1}'.replace(/<B>+<.B>/, ''); Quote Link to post Share on other sites
Praney Behl 314 Posted October 2, 2010 Report Share Posted October 2, 2010 Hey Biks, Use nested replace you don't need JavaScript, I have a post somewhere on the forum, do a little search... Praney Quote Link to post Share on other sites
UBotBuddy 331 Posted October 2, 2010 Report Share Posted October 2, 2010 I think you are okay. Jamming it into one node will not gain you much. AFterall, you're splitting hairs at that point. I use $replace instead of the javascript. Not that it matters but its another available path. Quote Link to post Share on other sites
Biks 9 Posted October 2, 2010 Author Report Share Posted October 2, 2010 Can you replace BOTH <B> and </B> at the same time? Or do you have to do two passes at it? I don't have that many hairs left (on my head) at this point. :-) Quote Link to post Share on other sites
Praney Behl 314 Posted October 2, 2010 Report Share Posted October 2, 2010 Can you replace BOTH <B> and </B> at the same time? Or do you have to do two passes at it? I don't have that many hairs left (on my head) at this point. :-) Yes you can just nest the replace function in one another , and bingo.. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.