Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想替换这样的数字:
Replace("55","a"); Replace("555","b");
我有数字555并想用字母替换它,b但是当我运行程序替换的代码时55,a输出将是这样的:a5
555
b
55
a
a5
我怎么解决这个问题??
您可以像这样翻转Replace呼叫:
Replace
var result = input.Replace("555", "b") .Replace("55", "a");
这将首先用 替换任何555' b,然后才用 替换任何剩余55的a。