2013-02-22 68 views
0

我正在爲6502彙編語言編寫定製的TextMate/Sublime Text 2包。我該如何用正則表達式來做到這一點?

無論如何,我希望能夠識別的常量,變量等

我有這樣的HEX編號:

<dict> 
    <key>match</key> 
    <string>#?\#[0-9a-fA-F]+</string> 
    <key>name</key> 
    <string>constant.numeric.decimal</string> 
</dict> 

但它並沒有真正用於以下工作:

#14    // works 
#$2F    // works 
#coolVariable // doesn't work. The "#c" is caught and colored but the rest is not. 
       //    In this case, I DON'T want any of it to be colored. 

就像代碼說的那樣,它不應該爲#coolVariable着色,而是抓住#c這一塊。

我想爲這些顏色分別着色。區分這兩種模式的正則表達式是什麼?

這樣:

#c0  // Caught by one pattern (values in decimal or hexadecimal or binary) 
#%10101 // Caught by one pattern (values in decimal or hexadecimal or binary) 
#c0BLAH // Caught by another pattern 

感謝

回答

0
\#[0-9a-fA-F]+\b 

爲了紀念這個詞必須在任何其他字符結束被使用。

0

使用\ b。對於字boundry

所以就把\b#?\#[0-9a-fA-F]+\b

相關問題