2009-07-20 1 views
3

通貨文字列を10進数値に変換するための数値書式設定があります。問題は、テキスト文字列に先頭のドル記号( "$")がない場合、有効な一致番号ではなく0に変換されることです。だから、:ここに

"$3.50" converts to 3.50 
"3.50" converts to 0 

は、コンバータのコードです:

// formatter to convert a value to and from a currency string 
NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init]; 
[currencyFormatter setNumberStyle:NSNumberFormatterCurrencyStyle]; 
[currencyFormatter setGeneratesDecimalNumbers:YES]; 

私は何かが足りないのですか?

答えて

1

同様の問題が発生しました。私は構文解析のためにNSNumberFormatterを廃止し、RegexKit Liteにはるかに良い結果をもたらしました。ここ

グラブコピー:RegexKit Lite

そして、ここhttp://regexlib.com/を行って、あなたに最適な正規表現を見つけます。

関連する問題