objective-c - iPhone : How to get the currency symbol from an amount string?
<p><p>我有一份不同货币的金额列表(例如 10.99 美元、20.55 欧元)。我想找出每个字符串的货币符号以解析金额。</p>
<p>你有什么想法吗?</p>
<p>问候。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您可以使用正则表达式查找第一个不是数字或小数分隔符的符号:</p>
<pre><code>NSError *error = NULL;
NSRegularExpression *symbol= [NSRegularExpression
regularExpressionWithPattern:@"[^0-9.,]"
options:NSRegularExpressionCaseInsensitive
error:&error];
NSRange r = [symbol
rangeOfFirstMatchInString:myString
options:0
range:NSMakeRange(0, )];
if (!NSEqualRanges(r, NSMakeRange(NSNotFound, 0))) {
NSLog(@"Currency symbol is '%@'", );
}
</code></pre></p>
<p style="font-size: 20px;">关于objective-c - iPhone : How to get the currency symbol from an amount string?,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/10384863/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/10384863/
</a>
</p>
页:
[1]