C# 在ms access中减去和更新字母数字字符串
我正在设计一个库存系统,我应该在每次销售产品时更新库存。我的股票栏如下所示: 股票 350公吨 500件 750公吨 1000公吨 现在我的要求可以分为两部分C# 在ms access中减去和更新字母数字字符串,c#,C#,我正在设计一个库存系统,我应该在每次销售产品时更新库存。我的股票栏如下所示: 股票 350公吨 500件 750公吨 1000公吨 现在我的要求可以分为两部分 如何从销售数量中减去这个字母数字字符串 更新时,单位也应与数字一起显示在DB中 任何帮助都将不胜感激为此使用正则表达式 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.Regula
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string input = "Stock 350 mts 500 pcs 750 mts 1000 mts";
// any word characters followed by any white spaces
// followed by any number of digits
string pattern = @"(?'name'\w+)\s+(?'quantity'\d+)";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
{
Console.WriteLine("Name : '{0}', Qnty : '{1}'", match.Groups["name"].Value, match.Groups["quantity"].Value);
}
Console.ReadLine();
}
}
}
为此使用正则表达式
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string input = "Stock 350 mts 500 pcs 750 mts 1000 mts";
// any word characters followed by any white spaces
// followed by any number of digits
string pattern = @"(?'name'\w+)\s+(?'quantity'\d+)";
MatchCollection matches = Regex.Matches(input, pattern);
foreach (Match match in matches)
{
Console.WriteLine("Name : '{0}', Qnty : '{1}'", match.Groups["name"].Value, match.Groups["quantity"].Value);
}
Console.ReadLine();
}
}
}
你为什么要这样储存?将这些单位单独存储到计数中不是更容易吗?非常感谢John,你的输入真的帮助了我,直到你提到它,我才意识到这一点。再次谢谢你为什么要这样储存?将这些单位单独存储到计数中不是更容易吗?非常感谢John,你的输入真的帮助了我,直到你提到它,我才意识到这一点。再次感谢