123456789101112131415161718192021222324252627 |
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- namespace YBEE.EQM.Core
- {
- /// <summary>
- /// 宏替换
- /// </summary>
- public class MacroReplacement
- {
- /// <summary>
- /// 宏替换
- /// </summary>
- /// <param name="input">要替换的字符串</param>
- /// <param name="macros">宏字典</param>
- /// <returns></returns>
- public static string Replace(string input, Dictionary<string, string> macros)
- {
- foreach (var macro in macros)
- {
- var regex = new Regex(macro.Key);
- input = regex.Replace(input, macro.Value);
- }
- return input;
- }
- }
- }
|