Javascript text for replacement link

I need to replace text with a link in

The link should look like this: "href =" / search? q = $ oldtext "title =" $ oldtext "". $ oldtext is the replacement text.

I am trying to use a loop to search for text with the regex "/ ^ \ x23 \ w /" and replace with a variable that contains the generated link. And this is useless. I edit the regexp to "/ \ x23 /" and get a replacement with "#" (\ x23 in hex as I hope =)) char in text mode only = (

Help me i'm stuck

Update: I have a text block between [span class = "text2replace"] super text #replacemetolink [/ span] I need to replace #replacemetolink with a link [a href = "/ timeline / search? Q = # replacemetolink" title = "# replacemetolink "class =" search-link "]. I am triying to use Opera's js for Twitter to replace #hashtags in a link to find this hashtag using Twitter search

0


a source to share


1 answer


You tried:

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

      



This will replace all instances of "$ oldtext" with the string stored in newText.

Kyle

+1


a source







All Articles