Solved

Cold Fusion Text Formatting

Posted on 2004-04-16
2
235 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

920 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

14 Experts available now in Live!

Get 1:1 Help Now