【发布时间】:2013-11-23 00:24:10
【问题描述】:
我遇到了一个问题,我很纠结。我有一段代码作为字符串读取,但我想删除它的特定部分。
/**
* This file is autoupdated by build.xml in order to set revision id.
*
* @author Damian Minkov
*/
public class RevisionID
{
/**
* The revision ID.
*/
public static final String REVISION_ID="0";
}
比如上面sn-p的代码。我想替换所有 cmets(/** 和 */ 之间的所有内容)。
我该怎么做呢?
现在,这是我正在尝试的;
var sposC = temp.indexOf('/*');
console.log(sposC);
var eposC = temp.indexOf('*/');
console.log(eposC);
var temp1 = temp.replace(eposC + sposC, '1');
它不起作用,所以请有人帮助我。
【问题讨论】:
-
使用正则表达式删除 cmets。见这里:stackoverflow.com/questions/5989315/…
标签: javascript string replace substring