Permalink
Browse files

Add support for some more edge cases (usd, quotes, slashes, nbn, nbln)

  • Loading branch information...
1 parent ec8d4b9 commit ad091abb35956430659b9fc8ff02eaa799b4adc6 Dustin Schneider committed Jun 21, 2012
Showing with 5 additions and 2 deletions.
  1. +1 −1 stocktwits-text.js
  2. +4 −1 test/tests.js
View
@@ -3,7 +3,7 @@ stwt = window.stwt || {};
(function() {
stwt.txt = {};
stwt.txt.regexen = {};
- stwt.txt.regexen.cashtag = /(^|[\s\,\.\-\+\(\/]\$?|^\$)(\$([a-z1-9]{1}[a-z]{1,3}_F|(?!\d+[bmkts]{1}?(il(lion)?)?\b|[\d]+\b)[a-z0-9]{1,9}(?:[-\.]{1}[a-z]{1,2})?(?:[-\.]{1}[a-z]{1,2})?))\b(?!\$)/ig;
+ stwt.txt.regexen.cashtag = /(^|[\s\,\.\-\+\(\/\"]\$?|^\$)(\$([a-z1-9]{1}[a-z]{1,3}_F|(?!\d+[bmkts]{1}?(il(lion)?|ln|m|n)?\b|[\d]+\b)(?!\d+usd)[a-z0-9]{1,9}(?:[-\.]{1}[a-z]{1,2})?(?:[-\.]{1}[a-z]{1,2})?))\b(?!\$)/ig;
stwt.txt.extractCashtags = function(text) {
var matches = [];
View
@@ -25,7 +25,10 @@ test("extractCashtags", function() {
["$LONGLONG", "LONGLONG"],
["($FOO)($BAR)", "FOO,BAR"],
["+$FOO-$BAR", "FOO,BAR"],
- ["$FOO/$BAR, $BAZ", "FOO,BAR,BAZ"]
+ ["$FOO/$BAR, $BAZ", "FOO,BAR,BAZ"],
+ ["$83BLN $5MM $3BLN $10BN", ""],
+ ["$50USD $3.10USD", ""],
+ ['"$AAPL" or "$GOOG"', "AAPL,GOOG"]
];
for(var i=0; i<tests.length; i++) {

0 comments on commit ad091ab

Please sign in to comment.