标签:reg window number user odi rms tar string 文本
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//List<string> ZZZString = new List<string>();//定义一个集合,用于储存数据
//StringBuilder StringBuilder = new StringBuilder();
//创建一个Click事件,用于打开读取文件
private void button1_Click(object sender, System.EventArgs e)
{
//System.Windows.Forms.OpenFileDialog objOpenFile = new System.Windows.Forms.OpenFileDialog();
//objOpenFile.Filter = "文本文档|*.txt";
//if (objOpenFile.ShowDialog() == DialogResult.OK)
//{
// //this.txtFile.Text = objOpenFile.FileName;
// string[] ReadText = File.ReadAllLines(objOpenFile.FileName, Encoding.Default);
// foreach (string item in ReadText)
// {
// foreach(char number in item)
// {
// //Regex regex = new Regex(@"^\d{24}$");
// if (Convert.ToInt32(number) >= 48 && Convert.ToInt32(number) <= 57)
// //if (item.ToUpper().Contains(""))//搜索指定字符串
// {
// //ZZZString.Add(number);//搜索到的内容存入ZzzString集合
// //ZZZString.Append(number.ToString());
// StringBuilder.Append(number);
// //richTextBox1.Text += item.ToString() + "\r\n";//添加一个richTextBox
// //label1.Text = ZzzString.Count + "条";//添加一个label
// }
// }
// if (!"".Equals(StringBuilder.ToString())) {
// richTextBox1.Text += "6J" + StringBuilder + "\n";
// StringBuilder.Clear();
// }
// }
//}
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
System.Windows.Forms.OpenFileDialog objOpenFile = new System.Windows.Forms.OpenFileDialog();
objOpenFile.Filter = "文本文档|*.txt";
if (objOpenFile.ShowDialog() == DialogResult.OK)
{
//this.txtFile.Text = objOpenFile.FileName;
string[] ReadText = File.ReadAllLines(objOpenFile.FileName, Encoding.Default);
int a = 0;string b = "";
foreach (string item in ReadText)
{
if (a == 1) {
string input_links = Regex.Replace(item," ", "");
richTextBox1.Text += "6J" + input_links + ":" + b + "\r\n";
a = 0;
}
if (item.ToUpper().Contains("6J")) {
a = 1;
}
if (item.ToUpper().Contains("(Z) A")) {
b = "ZA";
}
if (item.ToUpper().Contains("(Z) B")) {
b = "ZB";
}
if (item.ToUpper().Contains("(Z) C")) {
b = "ZC";
}
if (item.ToUpper().Contains("(Z) D")) {
b = "ZD";
}
}
System.IO.File.WriteAllText(@"C:\Users\LG\Desktop\提取的6J码.txt", richTextBox1.Text);
}
}
}
}
标签:reg window number user odi rms tar string 文本
原文地址:https://www.cnblogs.com/Lee597/p/14962520.html