Compressing text of x number of characters


    Jun 08 2008 | 3:01 pm
    I'm trying to create a simple patch that takes a sentence or word and only outputs the first 2 and last 2 characters with a symbol like a dash in between. Like this: "this is a long sentence" = "th-ce". I've currently trying to use regexp to do this using back references or substrings but I keep thinking that maybe it would be easier to do with javascript using the string.charAt method or similar.
    I need it to run fast though because it will be updated repeatedly and I don't know if using JS is the best solution for the rapid updating I need.

    • Jun 08 2008 | 3:16 pm
      On 8 juin 08, at 17:01, Wade wrote:
      > I'm trying to create a simple patch that takes a sentence or word and > only outputs the first 2 and last 2 characters with a symbol like a > dash in between. Like this: "this is a long sentence" = "th-ce". I've > currently trying to use regexp to do this using back references or > substrings but I keep thinking that maybe it would be easier to do > with javascript using the string.charAt method or similar.
      regexp works great for that:
      ej
    • Jun 08 2008 | 4:04 pm
      Nice and simple. Thanks a lot!
      On Sun, Jun 8, 2008 at 11:16 AM, Emmanuel Jourdan wrote: > On 8 juin 08, at 17:01, Wade wrote:
      > regexp works great for that: