删除< cfoutput>中的字符与ReplaceNoCase()ColdFusion [英] Remove characters in <cfoutput> with ReplaceNoCase() ColdFusion

查看:210
本文介绍了删除< cfoutput>中的字符与ReplaceNoCase()ColdFusion的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示格式类似于以下格式的数据记录的输出:XXXX:12345(Xxxxxxxxx)

I need to display an output from a data record that is formatted similar to this: XXXX:12345 (Xxxxxxxxx)

但是,我想输出的唯一数据是12345并且具有两个前面的零,即输出应该看起来像0012345。记录中的12345仅是示例,每个记录都分配有唯一的编号。示例记录如下所示:CAST:98765(RPOS1234-XY)

However, the only data I want to output is the "12345" and with two preceding zeros, i.e. the output should look like "0012345". The "12345" in the record is example only, each record has a unique number assigned. An example record looks like this: CAST:98765 (RPOS1234-XY)

我可以使用ReplaceNoCase()

Can I use the ReplaceNoCase() to pull only that data out of the record? If so, how would I write the code to remove the unwanted characters?

推荐答案

你可以在一行代码中使用

You can do this in one line of code using a few functions.

str = 'CAST:98765 (RPOS1234-XY)';
projectCode = '00' & listLast( listFirst( str, ' ' ), ':' );

writeDump( projectCode );

从内部函数出来解释这个代码。

To explain this code from the inner most function going out.

ListFirst()基于您指定的分隔符获取列表中的第一个元素,在这种情况下,分隔符为'' - 一个空格 - 是的,您可以使用空格作为分隔符。

ListFirst() gets the first element in an a list based on the delimiter you specify, in this case the delimiter is ' ' - a space - yes, you can use a space as a delimiter.

ListLast()根据您指定的分隔符获取列表中的最后一个元素,在这种情况下,分隔符为::

ListLast() gets the last element in a list based on the delimiter you specify, in this case the delimiter is ':'

第一部分simplet将'00'追加到上述函数调用的结果中。

The first part simplt appends '00' to the result of the above function calls.

这篇关于删除< cfoutput>中的字符与ReplaceNoCase()ColdFusion的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆