简体   繁体   English

正则表达式查找包装在某些XML标签中的非字母数字符号

[英]Regex to find non-alphanumeric symbols wrapped into certain XML tags

Hello everyone. 大家好。

I faced a little problem with Regular Expressions. 我在使用正则表达式时遇到了一个小问题。

I have a lot of XML files and I need to create a regex expression to find all instances of the following pattern: 我有很多XML文件,我需要创建一个正则表达式来查找以下模式的所有实例:

<text styleclass="" style="font-family:Calibri; font-size:11pt; color:#000000;">).</text>

In other words, I need to find each case when ). 换句话说,当时,我需要找到每种情况). are wrapped with the <text> tag. 用<text>标签包装。 Attributes in the opeining <text> tag may vary. 对应的<text>标记中的属性可能会有所不同。

Here are some sample sentences to play with: 以下是一些可搭配使用的例句:

<para styleclass="Normal">Password validity period specified in days (the <text styleclass="T_UIcontrol">Passport expiration check</text> parameter value is set to <text styleclass="T_Option">true</text> <text styleclass="" style="font-family:Calibri; font-size:11pt; color:#000000;">).</text></para>
<para styleclass="Normal">Password validity period specified in days (the <text styleclass="T_UIcontrol">Passport expiration check</text> parameter value is set to false <text styleclass="" style="font-family:Calibri; font-size:11pt; color:#000000;">).</text></para>

The best I came up with is (?<=(<\\/text>.))(<text.*>)(?=\\)\\.<\\/text>)(\\)\\.<\\/text>) , but in only works for the first sentence. 我想出的最好的是(?<=(<\\/text>.))(<text.*>)(?=\\)\\.<\\/text>)(\\)\\.<\\/text>) ,但仅适用于第一句话。

Can you give me any ideas or code samples to help creating an ultimate regex expression that will suitable for any cases? 您能否给我任何想法或代码示例,以帮助创建适用于任何情况的最终正则表达式表达式?

您可以使用此正则表达式:

<text[^>]*>\)\.</text>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM