【发布时间】:2018-07-19 20:45:38
【问题描述】:
public static string ToKebabCase(this string value)
{
if (string.IsNullOrEmpty(value))
return value;
return Regex.Replace(
value,
"(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])",
"-$1",
RegexOptions.Compiled)
.Trim()
.ToLower();
}
此方法制作字符串
"{branchId}/GetUser/{userId}" -> "{branch-id}/-get-user/{user-id}"
我需要:
"{branchId}/get-user/{userId}"
如何忽略花括号中的值?
【问题讨论】:
标签: c# .net regex regex-lookarounds