【发布时间】:2012-08-08 14:54:16
【问题描述】:
我有一个 xml 文件,在某些字段上需要有 60 个字符的限制。
例子
<Description>This is a long description that is really over 60 characters long and needs to be shortened</Description>
我需要修剪每一个出现的地方,所以它只有 60 个字符,所以上面的输出就是。
<Description>This is a long description that is really over 60 characters</Description>
使用记事本++,我将如何使用正则表达式进行搜索和替换?
我有多个文件需要对每个文件运行此操作,每个文件大约有 2000 行,并且该字段大约出现 10-15 次。
并非所有字段都超过 60 个字符,只是其中一些。
数据块示例
<Product>
<SuppliersProductCode>PF01215</SuppliersProductCode>
<BuyersProductCode></BuyersProductCode>
<GTIN>0</GTIN>
<Description>This is a long description that is really over 60 characters long and needs to be shortened</Description>
<Properties>
<Quantity UOMCode="EA">
<Packsize>1</Packsize>
<Amount>1</Amount>
</Quantity>
</Properties>
</Product>
谢谢
【问题讨论】:
-
对使用正则表达式很新,所以没有尝试太多设法让 find (
)(.*)( ) 位正确,但无法找出替换。跨度>