クリスのコードを関数に作り直し、配列をループすると、これは提供された文字列内の複数のハッシュ インスタンスに対して機能します。
<cffunction name="renderHash" output="false" returnType="string">
<cfargument name="text" required="true" type="string" hint="The text to render." />
<cfset var strText = arguments.text />
<cfset var strHash = '' />
<cfset var arrMatches = reMatch("<hash>(.*?)</hash>", arguments.text) />
<cfloop array="#arrMatches#" index="i">
<cfset strHash = reReplace(i, "<hash>(.*?)</hash>", "\1") />
<cfset strHash = reReplace(strHash, "[[:space:]]", "", "ALL") />
<cfset strHash = "##" & strHash />
<cfset strText = replace(strText, i, strHash) />
</cfloop>
<cfreturn strText />
</cffunction>
関数に変換する文字列を渡せば完了です。
<cfset strText = '<hash>Brad Thorm</hash> signs for the <hash>All Blacks</hash>' />
<cfset strConverted = renderHash(strText) />