我有以下文本文件:
清单版本:3.0.0
Ant版本:Apache Ant 1.7.1
创建时间:10.0-b19(Sun Microsystems Inc.)
Require-Bundle:org.eclipse.linuxtools.cdt.libhover; bundle-version =“ 1。
1.0“
Bundle-SymbolicName:com.qnx.doc.gestures.lib_ref
捆绑版本:3.0.0.20121120
包本地化:插件
捆绑包名称:%plugin.name
捆绑销售商:%plugin.providername
我正在尝试在replaceregexp任务中使用以下模式
regexp pattern ='Require-Bundle:org.eclipse.linuxtools.cdt.libhover; bundle-version =“ 1。 [\ s \ S] *'
最后这样:
清单版本:3.0.0
Ant版本:Apache Ant 1.7.1
创建时间:10.0-b19(Sun Microsystems Inc.)
1.0“
Bundle-SymbolicName:com.qnx.doc.gestures.lib_ref
捆绑版本:3.0.0.20121120
包本地化:插件
捆绑包名称:%plugin.name
捆绑销售商:%plugin.providername
问题是我不断得到这个:
清单版本:3.0.0
Ant版本:Apache Ant 1.7.1
创建时间:10.0-b19(Sun Microsystems Inc.)
1.0“
Bundle-SymbolicName:com.qnx.doc.gestures.lib_ref
捆绑版本:3.0.0.20121120
包本地化:插件
捆绑包名称:%plugin.name
捆绑销售商:%plugin.providername
我的正则表达式应该如何摆脱空行?
谢谢。
像这样的东西应该有效:
Require-Bundle: org\.eclipse\.linuxtools\.cdt\.libhover;bundle-version="1\.\s*1.0"\s*
Run Code Online (Sandbox Code Playgroud)
(用于\s*匹配零个或多个空白字符,其中包括\r和\n)但由于您正在处理清单文件,因此使用正确的清单解析器会更有意义。不幸的是,Ant<manifest>任务没有提供删除属性的方法,但它对于<script>任务来说非常简单:
<property name="manifest.file" location="path/to/manifest.txt" />
<script language="javascript"><![CDATA[
importPackage(java.io);
importPackage(java.util.jar);
// read the manifest
manifestFile = new File(project.getProperty('manifest.file'));
manifest = new Manifest();
is = new FileInputStream(manifestFile);
manifest.read(is);
is.close();
// remove the offending attribute
manifest.getMainAttributes().remove(new Attributes.Name('Require-Bundle'));
// write back to the original file
os = new FileOutputStream(manifestFile);
manifest.write(os);
os.close();
]]></script>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2625 次 |
| 最近记录: |