Extract root, month letter-year and yellow key from a Bloomberg futures ticker

Viewed 1449

A Bloomberg futures ticker usually looks like:

MCDZ3 Curcny

where the root is MCD, the month letter and year is Z3 and the 'yellow key' is Curcny.

Note that the root can be of variable length, 2-4 letters or 1 letter and 1 whitespace (e.g. S H4 Comdty). The letter-year allows only the letter listed below in expr and can have two digit years. Finally the yellow key can be one of several security type strings but I am interested in (Curncy|Equity|Index|Comdty) only.

In Matlab I have the following regular expression

expr = '[FGHJKMNQUVXZ]\d{1,2} '; 
[rootyk, monthyear] = regexpi(bbergtickers, expr,'split','match','once');

where

rootyk{:}
ans = 
    'mcd'    'curncy'

and

monthyear = 
    'z3 '

I don't want to match the ' ' (space) in the monthyear. How can I do?

4 Answers
Related