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.
我需要在资源文件中保存一个正则表达式,并且应该可以替换字符串中的第一个字符,替换特定的字符串等等
有可能这样做吗?
例如,正则表达式应该如何替换第一个字符?
替换第一个字符:
string res = Regex.Replace("text", "^.", "replacement");
替换最后一个字符:
string res = Regex.Replace("text", ".$", "replacement");