Compressing text of x number of characters

Jun 8, 2008 at 3:01pm

Compressing text of x number of characters

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.

#38294
Jun 8, 2008 at 3:16pm

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:

– Pasted Max Patch, click to expand. –

ej

#133299
Jun 8, 2008 at 4:04pm

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:

#133300

You must be logged in to reply to this topic.