Forums > MaxMSP

filtering repetitions of spaces

November 13, 2008 | 2:15 pm

I have a string like this:

"some text with lots of spaces"

I want it to be changed to:

"some text with lots of spaces"

I know the object I want is regexp and I know that I need to say:

‘Look for all spaces followed by any number of spaces and replace with one space’

but I can’t seem to write it out correctly.

I had a look at this but still struggling. Can someone point me in the right direction?

http://www.cycling74.com/story/2008/6/2/161813/1326

Thanks.


November 13, 2008 | 2:17 pm

That didn’t work as the forum filters out repetitions on spaces anyway.

Look at this patch:

– Pasted Max Patch, click to expand. –

Cheers.


November 13, 2008 | 2:30 pm

On 13 nov. 08, at 15:17, fairesigneaumachiniste wrote:

> That didn’t work as the forum filters out repetitions on spaces
> anyway.

Something like that should do it.

ej

– Pasted Max Patch, click to expand. –

November 13, 2008 | 3:39 pm

Thanks! That’s great!

I also found that doing [fromsymbol] – [tosymbol] worked but definitely not the best way.


November 14, 2008 | 12:56 am

> That didn’t work as the forum filters out repetitions on spaces
> anyway.

shortening multiple spaces into one is actually just a simple html feature, unless you explicitly write a "


November 14, 2008 | 12:02 pm

Emmanuel Jourdan schrieb:
> Something like that should do it.

yes, why easy if you can have it complicated… ;-)

– Pasted Max Patch, click to expand. –


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com


November 14, 2008 | 12:56 pm

Quote: jayrope wrote on Fri, 14 November 2008 01:56
—————————————————-
> > That didn’t work as the forum filters out repetitions on spaces
> > anyway.
>
> shortening multiple spaces into one is actually just a simple html feature, unless you explicitly write a "


November 14, 2008 | 1:08 pm

when writing javascript (or any code actually) you should use a dedicated code editor to strip out unwanted carriage returns, line breaks, tabs, spaces, etc.
a normal text software (like word) will unintentionally create those while you type, unless you set it to plain text edit (.txt) without any further visual formatting options.

i guess you knew this already?

i can recommend bbedit strongly for this (on mac).

jrp


Viewing 8 posts - 1 through 8 (of 8 total)