• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trimming off extra characters

New Here ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

Hi,

I am trying to find out what the CF Function is to trim characters off a variable. For example:

We have a series of variables for filenames such as 2007/filename.jpg, 2007/filename2.jpg, etc, and we want to program the Cold Fusion to strip off the 2007/ so that we are just left with the filename. We just can't seem to find the CF Tag to do that. Can anyone help?

Many Thanks.

GN
TOPICS
Advanced techniques

Views

337

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

Any one of these functions would do:

Right()
Mid()
RemoveChars()

It looks like you intend to remove the initial 5 characters everytime. So here:

<cfset oldName = "2007/filename2.jpg">
<cfset newName = removeChars(oldName, 1, 5)>
<cfoutput>#newName#</cfoutput>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

LATEST
Don't forget the replace and Regular Expression replace methods.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

AWESOME!

Have an excellent weekend!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2007 Apr 20, 2007

Copy link to clipboard

Copied

You have a slash-delimited list. You can also do the following:

<CFSET foo = ListLast(myString, "/")>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation