?
Solved

Cold Fusion Text Formatting

Posted on 2004-04-16
2
Medium Priority
?
242 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
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…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

770 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