在ColdFusion中使用短划线填充空格

bbu*_*ler 0 coldfusion

我需要创建一个CFM页面I,它将具有根据数据库中的数据构建的超链接.例如,我的数据库包含一列"标题"和一列"主题.来自"标题"和"主题"我将创建一个超链接(因为所有页面都遵循相同的方案:This-is-the-title-this-is-the-subject.html

所以问题是我需要在空格中输入" - ".因为现在我的CFOUTPUT就是这样的:This is the title this is the subject.html

有没有一种简单的方法将其转换为This-is-the-title-this-is-the-subject.html

小智 11

我认为这将解决您的问题

 <cfset pageName = "This is the title this is the subject.html" />
 <cfset seoPageName = replace(pageName," ","-","all") /> 
Run Code Online (Sandbox Code Playgroud)