views:

286

answers:

1

I need to replace text into link in

Link must be look like " href="/search?q=$oldtext" title="$oldtext" ". $oldtext is text to replace.

I'm tried to use loop to find text with regexp "/^\x23\w/",and replacing with variable that contain generated link. And it result to nothing. I've edit regexp to "/\x23/" and get replacing for "#" (\x23 in hex as I hope=)) char only in the text mode=(

Help me, I'm stuck

Update: I have text block between [span class="text2replace"]super text #replacemetolink[/span] I need to replace #replacemetolink into link [a href="/timeline/search?q=#replacemetolink" title="#replacemetolink" class="search-link"]. I'm triying to make usejs for Opera to Twitter to replace #hashtags into link for searching this hashtag using Twitter search

+1  A: 

Have you tried:

var newText = 'Query';
var link = ' href="/search?q=$oldtext" title="$oldtext" ';
link.replace("$oldtext", newText);

That would replace all instances of '$oldtext' with the string stored in newText.

Kyle

Kyle
Maybe I'd make wrong description, but I have text(!) and need to replace this text with link!Text is between <span> with own class "text2replace"
I'm not sure I understand what you are talking about, why don't you post some sample text and what it would look like after you replaced it.
Kyle
Look at my update message please!