有一段Java代码
public final String ACode="a"; public final String BCode="b"; public final String CCode="c"; public final String DCode="d"; public final String ECode="e"; public final String FCode="f"; public final String XCode="x"; public final String YCode="y"; public final String ZCode="z";
需要转换到Xml字符串,因为Java代码属性太多,直接硬编码太费时间,想到了Visual Studio.net的查找替换支持正则替换功能.
<string name="ACode">a</string> <string name="BCode">b</string> <string name="CCode">c</string> <string name="DCode">d</string> <string name="ECode">e</string> <string name="FCode">f</string> <string name="XCode">x</string> <string name="YCode">y</string> <string name="ZCode">z</string>
花了十来分钟Google到使用说明http://www.blog.163.com/free_for_all/blog/static/68718112012410538475/,下面这样即可达到效果.
查找项:public:bfinal:bString:b{[a-zA-Z_0-9]+}:b*=:b*"{[^\"]+}":b*;
替换为:<string name="\1">\2</string>
顺便记录下.
Visual Studio .Net使用正则表达式示例,布布扣,bubuko.com
时间: 2024-10-06 12:06:25