5322/26.81.12.31.00.01
请问下这种字符要怎么截取?

解决方案 »

  1.   


    不好意思啊,我没说清楚
    把红色字符截取出来并转换成 5322268112310001 这种格式的
    我看例子 写了个这样的 
    Regex reg = new Regex(@"(?is)[\d]{4}[\d]{2} [\d]{2} [\d]{2} [\d]{2} [\d]{2}"); 不知道怎么截取5322/26 和.符合。
      

  2.   

    下面还有很多这样规范的字符,我是想通过Regex 匹配逐一循环取出来的
      

  3.   

    \d{4}/\d{2}.\d{2}.\d{2}.\d{2}.\d{2}.\d{2}你可以直接去试试
      

  4.   

    string a = "5322/26.81.12.31.00.01";
    a.Replace("/", "").Replace(".", "")
      

  5.   

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                Regex rg=new Regex(this.textBox2.Text.Trim());
                Match mt;
                mt=rg.Match(this.textBox1.Text.Trim());
                if (mt.Success)
                {
                    label1.Text = mt.Groups[0].ToString();
                }
            }
        }
    }
      

  6.   

    转换为数字集合的话你可以string a = "5322/26.81.12.31.00.01";
    a.Replace("/", "").Replace(".", "") 
    也可以直接(\d{4})/(\d{2}).(\d{2}).(\d{2}).(\d{2}).(\d{2}).(\d{2})using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Text.RegularExpressions;namespace WindowsFormsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }        private void button1_Click(object sender, EventArgs e)
            {
                Regex rg = new Regex(this.textBox2.Text.Trim());
                Match mt;
                mt = rg.Match(this.textBox1.Text.Trim());
                if (mt.Success)
                {
                    label1.Text = "";
                    for (int i = 1; i < mt.Groups.Count; i++)
                    {
                        label1.Text += mt.Groups[i].ToString();
                    }
                }
            }
        }
    }