0
我有下面的XML數據。選擇數字前面的單詞
<para>The functions and duties of the CCS set out in s 6 CA are focused on promoting efficient market conduct and competitiveness of markets in Singapore. Consumer welfare, mentioned in the Singapore–US FTA, is not expressly mentioned as a purpose of the CA, nor is it expressly set out in the CA as an objective to be safeguarded by the CCS. However, CCS Guideline 1, at para 2.1 on “Purpose” of the CA makes reference to how consumers benefit as a consequence of competition. And this is equal to 2.1% of the entire data</para></footnote></para></item>
在這裏,我要捕捉後跟字para
或paras
或paras 1.2 and 0.8
數量,但如果數據是像general 1.2 and 1.3
我使用正則表達式是如下它不應該捕捉。
<xsl:template match="text()">
<xsl:analyze-string select="." regex="(([Cc]hapter)\s(\d+))">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="number(regex-group(3)) < number(9)">
<a href="{concat('er:#BGCL_CH_',format-number(number(regex-group(3)),'00'),'/','BGCL_CH_',format-number(number(regex-group(3)),'00'))}">
<xsl:value-of select="."/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:analyze-string select="." regex="([0-9]+)\.([0-9]+)">
<xsl:matching-substring>
<xsl:choose>
<xsl:when test="number(regex-group(1)) < number(9)">
<a
href="{concat('er:#CLI_CH_',format-number(number(regex-group(1)),'00'),'/P',format-number(number(regex-group(1)),'0'),'-',format-number(number(regex-group(2)),'000'))}">
<xsl:value-of select="."/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:analyze-string select="." regex="http://[^ ]+">
<xsl:matching-substring>
<a href="{.}">
<xsl:value-of select="."/>
</a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
但在這裏它是捕捉x.y
格式的任意數字,我想只有當文本是在下列格式捕捉
para x.y
paras x.y and x.y
,我想轉換th e x.y
納入以下格式
er:#BGCL_CH_x/Px-y
請讓我知道我該怎麼做。
感謝