0

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
  • Why are you trying to find text with a '#' in it? That character doesn't appear anywhere in the string you want to modify. Can you edit the question to explain what you are trying to do more clearly? Commented May 22, 2009 at 19:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.