gpt4 book ai didi

javascript - 删除字符串的一部分 javascript 不起作用

转载 作者:行者123 更新时间:2023-12-02 19:48:27 26 4
gpt4 key购买 nike

我正在尝试删除该字符串的第二部分(第二个 block )

<resourceDescriptor name="report_mongodb_new_basic" wsType="reportUnit"  uriString="/reports/samples/report_mongodb_new_basic" isNew="false">
<label><![CDATA[report mongodb new basic]]></label>
<description><![CDATA[test 3]]></description>
<creationDate>1330693884348</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.jasperreports.domain.ReportUnit]]></value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value><![CDATA[/reports/samples]]></value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value><![CDATA[0]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_ALWAYS_PROPMT_CONTROLS">
<value><![CDATA[false]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_CONTROLS_LAYOUT">
<value><![CDATA[1]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_REPORT_RENDERING_VIEW">
<value><![CDATA[]]></value>
</resourceProperty>
<resourceDescriptor wsType="datasource" isNew="false">
<resourceProperty name="PROP_REFERENCE_URI">
<value><![CDATA[/datasources/MongoDB]]></value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value><![CDATA[true]]></value>
</resourceProperty>

<resourceDescriptor name="report_mongodb_new_basic_" wsType="jrxml" uriString="/reports/samples/report_mongodb_new_basic_files/report_mongodb_new_basic_" isNew="false">
<label><![CDATA[report mongodb new basic]]></label>
<creationDate>1330693884348</creationDate>
<resourceProperty name="PROP_RESOURCE_TYPE">
<value><![CDATA[com.jaspersoft.jasperserver.api.metadata.common.domain.FileResource]]></value>
</resourceProperty>
<resourceProperty name="PROP_PARENT_FOLDER">
<value><![CDATA[/reports/samples/report_mongodb_new_basic_files]]></value>
</resourceProperty>
<resourceProperty name="PROP_VERSION">
<value><![CDATA[0]]></value>
</resourceProperty>
<resourceProperty name="PROP_IS_REFERENCE">
<value><![CDATA[false]]></value>
</resourceProperty>
<resourceProperty name="PROP_HAS_DATA">
<value><![CDATA[true]]></value>
</resourceProperty>
<resourceProperty name="PROP_ATTACHMENT_ID">
<value><![CDATA[attachment]]></value>
</resourceProperty>
<resourceProperty name="PROP_RU_IS_MAIN_REPORT">
<value><![CDATA[true]]></value>
</resourceProperty>
</resourceDescriptor>

我只想要第一个 block (From : <resourceDescriptor to </resourceDescriptor>我目前正在这样做,但它不起作用:

var sbody = a.body; //sbody is a String
sbody.split("</resourceDescriptor>").pop();
console.log(sbody);

结果没有改变(COsole.log是nodejs,它是打印)或

sbody.substring(sbody.indexOf("<resourceDescriptor>") + 1, sbody.indexOf("</resourceDescriptor>"));
console.log(sbody);

结果也没有变化,为什么?

谢谢

最佳答案

pop 返回弹出的值,它不会改变对象/数组 它遭到反对;

var result = sbody.split("</resourceDescriptor>").pop();
console.log(result);

关于javascript - 删除字符串的一部分 javascript 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9599889/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com