Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6096833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:58:23+00:00 2026-05-23T12:58:23+00:00

UPDATE 1: Really sorry about this, I just realised I made a mistake with

  • 0

UPDATE 1:

Really sorry about this, I just realised I made a mistake with the question.

If data = some @text1 here, and @text2 here

It should become

some <a href="http://www.google.com/?q=text1">@text1</a> here, and <a href="http://www.google.com/?q=text2">@text2</a> here

ORIGINAL QUESTION:

Using jQuery AJAX, I am returning data and outputting it like this:

$('.class_name_here').append( data )

Within data I want to be able to search for certain characters, then add urls to them before outputting them, e.g.

lets say data contains

some @test here

I want to find the word which follows after @ and add http://www.google.com to it, so I end up with

some <a href="http://www.google.com">@test</a> here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:58:24+00:00Added an answer on May 23, 2026 at 12:58 pm
    var str = 'test @google test';
    str = str.replace(/(@\w+)/g,'<a href="http://google.com/">$1</a>');
    alert(str);
    

    Should work, a simple regex replace. And a nice demo can be found here.

    Update:

    Try this on for size:

    // place somewhere in global scope (in head of document for instance)
    String.prototype.addGoogleLinks = function(){
        return this.replace(/(@(\w+))/g,'<a href="http://google.com/?q=$2">$1</a>');
    };
    
    // reference the data variable and call the addGoogleLinks()
    // which will return the formatted string
    data.addGoogleLinks()
    

    That will wrap all @keywords in a <a href="http://google.com/?q=keywords">@keywords</a>, for instance.

    Demo of this, too

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really suffering here trying to get this ajax call to work, sorry
Update: I am sorry i pasted in list.xml twice by mistake, my question is
Sorry, I'm not sure how to really word my question. Here it goes. If
(Sorry if this is a really long question, it said to be specific) The
First let me say I really sorry for asking a question about facebook. I'm
i'm really sorry if this question have been asked before but I couldn't find
Sorry if this sounds stupid but I'm really new to LiftWeb and just struggling
Sorry i really didn't know how to phrase the question any better but here
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
Update: Check out this follow-up question: Gem Update on Windows - is it broken?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.