货币符号的 Java 正则表达式
AI-摘要
切换
Tianli GPT
AI初始化中...
介绍自己
生成本文简介
推荐相关文章
前往主页
前往tianli博客
货币符号的 Java 正则表达式
在本教程中,我们将学习匹配所有可用的货币符号,例如美元,欧元,日元,日元。
解决方案正则表达式:
\\p{Sc}
使用 Java 正则表达式匹配任何货币符号的示例代码
String content = "Let's find the symbols or currencies : $ Dollar, € Euro, ¥ Yen";
String regex = "\\p{Sc}";
Pattern pattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(content);
while (matcher.find())
{
System.out.print("Start index: " + matcher.start());
System.out.print(" End index: " + matcher.end() + " ");
System.out.println(" : " + matcher.group());
}
Output:
Start index: 39 End index: 40 : $
Start index: 49 End index: 50 : €
Start index: 57 End index: 58 : ¥
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 程序员小航
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果
