2016-12-19 2 views
0

内の文字列切削:異なる括弧内 Decrease with an active address (2)またはUnsecured task (100)など私は次のようになります。私のクエリの値を持っているColdFusionの

値は、それがこのために1、2、3桁以上にすることができますカウント値です。

括弧や値ではなく、説明を取得するだけです。 は、だから私は必要なものだけです:

Decrease with an active address 
Unsecured task 

など

どのように私は、開口部(、数値と決算)を取り除くことができますか?

ColdFusion 8では?

+1

'reReplace()'で。または、必要なものが常に最後にある場合は、 'left()'と 'find()'の組み合わせが機能します。 –

答えて

2

ダンは1つのオプションremove any text within parenthesisに適切な表現でreReplace()を使用して、コメントで述べたように:あなただけしたい場合は、コメントで述べたAlexよう

<cfscript> 
    origText = "Decrease with an active address (2)"; 
    newText = reReplaceNoCase(origText, "\([^)]*\)", "", "all"); 
    writeDump(newText); 
</cfscript> 

を更新文字列を「切り取って」、の前に括弧を付けてと入力してください。

<cfscript> 
    origText = "Decrease with an active address (2) plus more text after the parenthesis"; 
    newText = reReplaceNoCase(origText, "\([0-9]*\).*$", "", "all"); 
    writeOutput("<br>"& newText); 
</cfscript> 
+1

そして、数字のついた括弧だけを削除したい場合は、 'reReplaceNoCase'の第2引数として' \([0-9] * \)$ 'を使います。 – Alex

+0

@Alex - それは良い点です。私はそれを「削除する」と読むが、タイトルを見て、あなたの提案はおそらくマークに近いだろう。 – Leigh

関連する問題