2 Replies Latest reply on Jun 9, 2009 2:19 AM by kel45

    string replace issue

    kel45 Level 1

      hi i have a string variable called "displayText" which can be about 160 chars, some of these strings have no spaces in, so when displaying in a html table the text does not wrap.


      so i need to somehow do this

      1. if the string contains no spaces then

      2. count every 40 chars and add a br


      if someone could help me


      many thanks


        • 1. Re: string replace issue
          mack_ Level 3
          /*  You can also use a regular expression here to search for tabs,
          newlines, etc  */
          if( string does not contain " " and Len(string) gt 40 ) {
            wrappedString = "";
            /*  place a <br> after each 40 chars  */
            while( i lte Len(string) ) {
              wrappedString = wrappedString & Mid(string, i, 40);
              i = i + 40;
              /*  Don't place a <br> at the end */
              if( i lte Len(string) ) {
                wrappedString = wrappedString & "<br>";



          • 2. Re: string replace issue
            kel45 Level 1

            Hi Many thanks for your help, its not quite working because...


            some of the strings do contain space at the start, so the script would not be hit, a string example is


            test test test,test,test,test,test,test,test,test,test,test,test,test,test,test,test,test,test,test , test test


            what i need to do is find if the string contains a substring of 40 chars with no spaces if so add a br at the 40th char