Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert character in text

Status
Not open for further replies.

twcman

Programmer
Joined
Jun 28, 2001
Messages
284
Location
US
I have a list of times (100,200,300, etc.) that come from a database table. On output, I would like to insert a : before the last two digits (1:00,2:00, etc).

Could some one point me in the right direction?

The only dumb questions are the ones that are never asked
 
you can use the insert command. this will allow you to insert a substring anywhere into another string.

<CFSET dbLength = (Len(dbField) - 2)>

<CFSET out = Insert(&quot;:&quot;, dbField, dbLength)>

<cfoutput>
#out#
</cfoutput>

Hope this works !!
 
You can use a regular expression

<cfset vList = &quot;100,200,300&quot;>
<cfset vNewList = ReReplace(variables.vList, &quot;(
Code:
[
Code:
[
:digit:
Code:
]
Code:
]
)(
Code:
[
Code:
[
:digit:
Code:
]
Code:
]
{2})&quot;
, &quot;\1:\2&quot;, &quot;ALL&quot;)>
- tleish
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top