【发布时间】:2021-12-28 15:51:07
【问题描述】:
我有以下模式:
UnallowedCharacters = @"<>\{\}" + "\"";
@"^(?<contactType>\d+):(?<contactIdentifier>[^;" + UnallowedCharacters + @"]+)(;(?<parameterName>[A-Za-z0-9_-]+)=(?<parameterValue>[^;=" + UnallowedCharacters + "]+))*$"
我需要允许在contactIdentifier 部分使用分号,但仍然不能从不允许的字符中排除分号,因为以后的拆分将不再起作用。
输入和预期输出的两个示例如下:
- 输入:
"8:test;aliases=1:test@outlook.com,4:test"=> 解析后,预期输出应为"8:test"forcontactIdentifier部分 - 输入:
"8.test;.person@domain.com;aliases=1:test@outlook.com,4:test"=> 解析后,预期输出应为"8:test;.person@domain.com"forcontactIdentifier部分
分号用于在解析过程中将未解析的字符串拆分为多个部分,但我希望允许在contactIdentifer字符组中使用它而不影响现有的匹配和解析逻辑。
有什么想法吗?
【问题讨论】:
-
UnallowedCharacters目前不包含分号,那么,问题解决了吗?如果没有,请发布示例输入(有效和无效) -
见稍后编辑。 :)
-
@MathiasR.Jessen 请参阅编辑。