可能是正则运算表达式问题,请帮忙.
using System;using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
test te = new test();
Console.WriteLine(te.codeNumber("AB00230001", 5000));
}
class test
{
public string codeNumber(string source, int num)
{
string str1 = Regex.Match(source, @"[0-9]+", RegexOptions.RightToLeft).Value;
string begin = str1.Substring(0, source.Length - str1.Length);
return begin + (int.Parse(str1) + num-1).ToString().PadLeft(str1.Length, char.Parse("0"));
}
}
}
}
上面几行代码.
当 Console.WriteLine(te.codeNumber("AB00230001", 5000));
时,结果是0000235000,但我想要的是AB00235000,请问函数要改那里?