2012-03-16 61 views
3

我有一個字符串即時通訊工作的矢量trought,我需要檢查字符串是如何形成的。 我在函數的其餘部分使用sscanf,我需要這樣的東西。檢查字符串的格式

if (format("%f,%f,%f")) { 
    // Do someting 
} else if (format("%d,%d")) { 
    // Do something else 
} else { 
    // Do something 
} 

這是可能的使用sscanf或從std?

+0

應該可能使用正則表達式庫 – unexplored 2012-03-16 17:47:15

回答

1

如果您能夠使用tr1那麼std::tr1::regex是..去看看here

+1

或者如果您可以使用C++ 11,則可以使用'std :: regex',而不使用tr1。 – bames53 2012-03-16 17:49:21