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 7952151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:46:31+00:00 2026-06-04T02:46:31+00:00

I am trying to write something that would look at tweets and pull up

  • 0

I am trying to write something that would look at tweets and pull up info about stocks being mentioned in the tweet. People use $ to reference stock symbols on twitter but I cant escape the $.

I also dont want to match any price mention or anything like that so basically match $AAPL and not $1500

I was thinking it would be something like this

\b\$[a-zA-Z].*\b

if there are multiple matches id like to loop through them somehow so something like

while ((tweet = reg.exec(sym_pat)) !== null) {
   //replace text with stock data.
}

This expression gives me an unexpected illegal token error

 var symbol_pat = new RegExp(\b\$[a-z]*);

Thanks for the help if you want to see the next issue I ran into
Javascript AJAX scope inside of $.each Scope

  • 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-04T02:46:33+00:00Added an answer on June 4, 2026 at 2:46 am
    var symbol_pat = new RegExp('\\b\\$[a-z]+\\b','gi');
    // or
    var symbol_pat = /\b\$[a-z]+\b/gi;
    

    Also, for some reason JS can not calculate the beginning of a word by \b, it just catches the one at the end.

    EDIT: If you’re replacing the stock symbols you can use the basic replace method by a function and replace that data with predefined values:

    var symbol_pat = /(^|\s)(\$[a-z]+\b)/gi;
    var stocks = {AAPL:1,ETC:2}
    var str = '$aapl ssd $a a$s$etc $etc';
    console.log(str);
    str = str.replace(symbol_pat, function() {
        var stk = arguments[2].substr(1).toUpperCase();
        // assuming you want to replace $etc as well as $ETC by using
        // the .toUpperCase() method
        if (!stocks[stk]) return arguments[0];
        return arguments[0].replace(arguments[2],stocks[stk]);
    });
    console.log(str);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to sort an array that would look something like this: (please ignore
I am trying to write something that will fire an event anytime the hard
I'm trying to write something that calls a function at runtime without using reflection.
I'm trying to write a query that gives me a percentage (i.e. something like
I'm trying to write a ranked match/searching system for a client that will look
I am trying to write a very simple script that would simulate a pocket
Im trying to write something to get my images to show correctly. I have
I'm trying to write something very similar to an IM client (for learning purposes
I'm trying to write something similar to this (sorry if the sample is not
I am trying to write something in c++ with an architecture like: App -->

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.