Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Cold Fusion Text Formatting

Posted on 2004-04-16
2
Medium Priority
?
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 375 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

636 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