Solved

Cold Fusion Text Formatting

Posted on 2004-04-16
2
234 Views
Last Modified: 2010-04-06
I need a bit of help with Cold Fusion text trimming and formatting.

I have a string that will output from the database looking like this

The McDermont 72in
The Shea 55in
etc...

I need to make them display without the measurements. My plan was to do the following:

* Get the position of the second space
* Trim off everything to the right of that
* Save that into a variable and use that as the display

I need help with the function to find position of the second occurance of a space
AND
I need help with the command to capture the portion of the string I want using the value from the first function.

Thanks
0
Comment
Question by:comfixit
2 Comments
 
LVL 10

Expert Comment

by:stu215
ID: 10860180
there are three functions you could use to do this :

LEFT              : Left(string, count)
MID               : Mid(string, start, count)
and RIGHT      : Right(string, count)

For your goal, Id suggest MID, however all of those functions require that you know where you want to start in the string.
if the end part is always 4chars then you could do :

<cfset temp=#<yourstring>.length#>
<cfset #temp#=#temp#-4>

Using Mid :
#Mid(<yourstring>, 0, temp)#    

Using Left :
#Left(<yourstring>, temp)#

~Stu :-)
0
 

Accepted Solution

by:
DJArigan earned 125 total points
ID: 10871688
<!--- Here: --->
<CFSET temp = "The McDermont 72in">

<!--- To get the position of the second space use: --->
<CFSET p = find(temp, " ", find(temp, " ") + 1)>

<!--- Removing everything aftwards --->
<CFSET temp = left(temp, p - 1)>
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now