How to strip of characters when long text is displayed?

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default How to strip of characters when long text is displayed?

    Hi,

    I was wondering if anyone had some function or has had to strip off characters
    from a long string. We have a user inteface, and the text is long, like we
    display 'descriptions' but I want to "SNIP" the text off a set point and then
    have the trailing ...... at the end.

    This seems like a common thing... any ideas.

    -WestSide

    WestSide Guest

  2. Similar Questions and Discussions

    1. strip span tag from text-only templates
      Hi, I am building a control that renders as a table, and I created two templates for my users to "wrap" the table with whatever HTML tags they...
    2. Swedish characters not displayed in datagrid
      I'm retrieving data from a Sybase database and loading it into a dataset and displaying it in a datagrid. The problem that I'm having is the swedish...
    3. how to read japanese characters (multilingual characters) from a text file and save them in Access database ???
      HI All i m trying to read a text file, having some japanese characters and saved as UTF-8 encoding. I m using ASP,FSO ... my code is below,...
    4. String manipulation of a URL - strip preceding characters?
      How would I strip out everything from before the last "/" in the following string generated from request.servervaraibles method: ...
    5. Strip Leading Characters ??
      I'd like to strip various leading characters from a registration number. for example MA1234 = 1234 987651 = 987651 Q10001 = 10001 The code...
  3. #2

    Default Re: How to strip of characters when long text isdisplayed?

    <cfset LongDescription = 'This is a sample of more than 25 characters of text'>
    <cfoutput> <cfif Len(LongDescription) GT 25> #Left(LongDescription, 25)#...
    <cfelse> #LongDescription# </cfif> </cfoutput>

    CriticalIM Guest

  4. #3

    Default Re: How to strip of characters when long text isdisplayed?

    Another approach, if you want it to look a little better, is to define the
    maximum length you want and then find a breaking point (space, period, question
    mark, etc.) to trim the string. In this example, I take the text of an
    article,extract the first 75 characters, and reverse them. The I look for one
    of these break points, copy the string (MID function) from that point on,
    reverse it again, and add the trailing ... at the end. Works pretty well.
    -Paul Paul Dempsey Dickinson College

    <CFSCRIPT>
    tempsyn = Reverse(Left(rsDate.article,75));
    artsyn = Reverse(Mid(tempsyn,FindOneOf(". ?!",tempsyn),75)) & "...";
    </CFSCRIPT>

    dempster Guest

  5. #4

    Default Re: How to strip of characters when long text isdisplayed?

    Try this for some reusability...
    <cfscript>
    function snipString(argString, argLength){
    var rtnString = left(argString,argLength);
    if(Len(argString) gt argLength)
    rtnString = rtnString & '...';
    return rtnString;
    }
    </cfscript>
    <cfset LongDescription = "This is a sample of more than 25 characters of
    text">
    <cfoutput>#snipString(LongDescription,25)#</cfoutput>

    kyle969 Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139