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

  • Home
  • SEARCH
  • 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 8791687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:52:39+00:00 2026-06-13T22:52:39+00:00

I have this beautiful function, but I need to customize it to return just

  • 0

I have this beautiful function, but I need to customize it to return just an array of items matching the regex. so the result would be #hash1234, #sweetthing,#something_notimportant Is there any way to do this using this function?

String.prototype.parseHashtag = function() {
    return this.replace(/[#]+[A-Za-z0-9-_]+/g, function(t) {
        var tag = t.replace("#", "%23");
        return t.link("http://search.twitter.com/search?q=" + tag);
    });
};

var string = '#hash1234 this is another hash: #sweetthing and yet another #something_notimportant';       
$('#result').html(string.parseHashtag());
  • 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-06-13T22:52:40+00:00Added an answer on June 13, 2026 at 10:52 pm

    The .match method returns an array of all matches, or null if there were no matches.

    So if null is an acceptable return for the no-match situation then:

    String.prototype.parseHashtag = function() {
        return this.match(/[#]+[A-Za-z0-9-_]+/g);
    }
    

    Or if you’d prefer to return an empty array or other default for no-match:

    String.prototype.parseHashtag = function() {
        return this.match(/[#]+[A-Za-z0-9-_]+/g) || [];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have an array like this: $array = array (this,is,me,and,I,am,an,array,hello,beautiful,world); How can
I have this xml <products> <product> <name>Demo</name> </product> <product> <name>Black Beauty III</name> <description>Beautiful les
I have this form, in which i need to populate a combo box with
I have this function // add history paths and save data function AddPath( strTag,
I have this script: http://jsfiddle.net/NV2uV/ It works, but I do not like it. Cons:
Hi I have made this function that takes a table and prepare the label
I saw this beautiful script to add thousands separator to js numbers: function thousandSeparator(n,
Ok, I have looked and looked but cannot seem to find anything on this
I have this jQuery code, which uses the toggle() function on a checkbox input
let's say that I have this function in Rails (I have actually :P -

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.