小编Ram*_*aid的帖子

23
推荐指数
3
解决办法
5万
查看次数

正则表达式从字符串中删除任何货币符号?

我正在尝试从字符串值中删除任何货币符号.

using System;
using System.Windows.Forms;
using System.Text.RegularExpressions;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string pattern = @"(\p{Sc})?";
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            decimal x = 60.00M;
            txtPrice.Text = x.ToString("c");
        }

        private void btnPrice_Click(object sender, EventArgs e)
        {
            Regex rgx = new Regex(pattern);
            string x = rgx.Replace(txtPrice.Text, "");
            txtPrice.Text = x;
        }
    }
}
// The example displays the following output:
// txtPrice.Text = "60.00";
Run Code Online (Sandbox Code Playgroud)

这有效,但不会删除阿拉伯语中的货币符号.我不知道为什么.

以下是带有货币符号的示例阿拉伯字符串.

txtPrice.Text = "?.?.? …
Run Code Online (Sandbox Code Playgroud)

c# regex

5
推荐指数
1
解决办法
6204
查看次数

标签 统计

c# ×1

regex ×1

sql-server ×1

sql-server-2005 ×1