I have the following code (AS3 & CS 5.5):
var regEx:RegExp = new RegExp(/(?:^|\s)(\#[^\s$]+)/g);
var txt:String = "This #asd is a test tweet #hash1 test #hash2 test";
var matches:Object = regEx.exec(txt);
trace(matches);
The trace returns ‘#asd,#asd’. I really don’t understand why it would to this, as in my RegEx testing application ‘RegExhibit’ it returns ‘#asd,#hash1,#hash2’, which is what I’d expect. Can anyone shed any light on this please?
Thanks in advance!
If you are using
.exec, you should run it multiple times to get all results:Source: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/RegExp.html
A better alternative is probably to use
String.match:An example should be (not tested):