RegExp,删除标签中的点

Nic*_*ajB 5 c# regex

我一直在搜索和搜索,但找不到解决方案.
我需要在c#中使用RegExp删除XML doc标签中的点.

例如:

test <12.34.56>test.test<12.34>
Run Code Online (Sandbox Code Playgroud)

应该:

test <12346>test.test<1234>
Run Code Online (Sandbox Code Playgroud)

所以基本上删除点,但只在标签....任何想法?

Tim*_*ker 5

resultString = Regex.Replace(subjectString, @"\.(?=[^<>]*>)", "");
Run Code Online (Sandbox Code Playgroud)

仅当下一个下一个尖括号是一个结束尖括号时,才用空字符串替换一个点.

这当然是脆弱的,因为在标签之间的文本内部可能会出现关闭尖括号,但如果您确定不会出现这种情况,那么您应该没问题.

说明:

\.      # Match a dot
(?=     # only if the following regex can be matched at the current position:
 [^<>]* #  - zero or more characters except < or >
 >      #  - followed by a >
)       # End of lookahead assertion
Run Code Online (Sandbox Code Playgroud)