由网友(人潮拥挤怎么没挤死你)分享简介:我需要使用楠更新.js文件中一个特定的行。该生产线将是这样的:I need to use NAnt to update one specific line in a .js file.The line will be something like:global.ServerPath = 'http://serv...
我需要使用楠更新.js文件中一个特定的行。 该生产线将是这样的:
I need to use NAnt to update one specific line in a .js file. The line will be something like:
global.ServerPath = 'http://server-path/';
我需要一种方法来更新目标服务器的该行的服务器路径的一部分。 ReplaceString是没有好,因为我不知道是什么文件中的路径是,当我更新。
I need a way to update the "server-path" part of that line with that of the destination server. ReplaceString is no good, since I won't know what the path in the file is when I update it.
任何帮助吗?
在此先感谢
推荐答案
如果字符串::替换
不起作用<正则表达式>
可以做的工作。这是它:
If string::replace
doesn't work <regex>
can do the job. This is it:
<?xml version="1.0" encoding="utf-8" ?>
<project name="replace.line" default="replace">
<target name="replace" descripton="replaces a line">
<property
name="js.file"
value="C:foo.js" />
<loadfile file="${js.file}" property="js.file.content" />
<regex
input="${js.file.content}"
pattern="(?'BEFORE'.*)global.ServerPaths*=s*'[^']*';(?'AFTER'.*)" />
<echo
file="${js.file}"
message="${BEFORE}global.ServerPath = 'http://bla/';${AFTER}"
append="false" />
</target>
</project>
相关推荐
最新文章