3 Replies Latest reply on Apr 7, 2011 11:06 AM by Golden Pelican

    wbr every 5 characters in really long string

    Golden Pelican

      I have some users put in really long strings in a text area and when it's displayed the formatting is thrown off because there are no spaces. To fix this I want to insert a wbr every 5 spaces that gives the browser the option to break if it needs to. I have it working in javascript and a version working in coldfusion, but the coldfusion version inserts the wbr every other character. Any idea how to insert a wbr every 5 characters with a REReplace()?





      <script type="text/javascript" language="JavaScript">

      str = '#really_long_text#';

      str = str.replace(/(.{5})/g,'$&<wbr/>');





      <cfset str = REReplace(really_long_text, "(.{0})", "<wbr>", "all">

      again this does it every other character, but I need it every 5 characters