Forums > MaxMSP

Regexp and '&' woes

November 22, 2006 | 7:33 pm

Original text is

Another & another is never enough. I want all I want nothing, no in between
… I’ll miss & my soul will be in it. I want all I want nothing, no in
between …
—————————————————————————————————————

Coll stores as

"Another &
another is never enough. I want all I want nothing, no in between … I’ll
miss &
my soul will be in it. I want all I want nothing, no in between …"
——————————————————————————————————–

How do I get regexp to substitute the ‘&’ with an ‘and’ ?
I would like there to be no ‘unmatched’ string that shows up.

Substitution like this……
Another and another is never enough. I want all I want nothing, no in
between … I’ll miss and my soul will be in it. I want all I want nothing,
no in between …

——————————————————————————————————
so far…………………..

#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P comment 793 33 100 196617 NOPE!;
#P comment 246 264 100 196617 Coll stores as;
#P message 796 87 86 196617 re &([^&]*)\\W;
#P message 796 107 139 196617 re &([^&]*)[^&]+\\w*\\W;
#P message 796 186 118 196617 re &amp\\\;\\w*\\W;
#P message 796 158 94 196617 re &amp|&([^&]*);
#P message 345 130 66 196617 re &([^&]*);
#B color 6;
#P message 796 66 129 196617 re &(.*?)\\W|&([^&]*).;
#P window linecount 3;
#P message 247 283 392 196617 "Another &amp\;
another is never enough. I want all I want nothing\, no in between …
I’ll piss &amp\;
my soul will be in it. I want all I want nothing\, no in between …";
#P window linecount 1;
#P message 248 441 137 196617 spcnet. … SPCNET.TV &gt\;;
#P message 248 526 203 196617 I love MiMi pictures from scenery &amp\;;
#P window linecount 2;
#P message 248 473 254 196617 http://www.i love dmypet.com/view.asp?
id=13483&amp\; preview=yes&amp\;;
#P message 248 335 226 196617 The group &amp doesn’t have a name. See their
&quot website at http//:www.sucks.com &don.;
#P hidden comment 86 298 40 196617 _show_ window;
#P window linecount 1;
#P hidden newex 29 261 48 196617 loadbang;
#P hidden message 29 283 29 196617 open;
#P hidden newex 29 305 51 196617 pcontrol;
#B color 5;
#P button 88 322 33 0;
#N vpatcher 1027 49 1622 488;
#P origin -40 24;
#P window setfont "Sans Serif" 9.;
#P comment 21 218 79 196617 Backreferences;
#P hidden message -1 53 14 196617 -;
#P hidden inlet 0 31 15 0;
#P message 187 310 577 196617 -;
#P window linecount 3;
#P message 137 257 443 196617 "&amp\;
another is never enough. I want all I want nothing\, no in between …
I’ll piss " "&amp\;
my soul will be in it. I want all I want nothing\, no in between …";
#P window linecount 2;
#P message 110 215 432 196617 "amp\;
my soul will be in it. I want all I want nothing\, no in between …";
#P window linecount 1;
#P message 68 153 492 196617 Another andand;
#P hidden newex 256 118 62 196617 prepend set;
#P hidden newex 182 118 62 196617 prepend set;
#P hidden newex 84 118 62 196617 prepend set;
#P hidden newex -1 118 62 196617 prepend set;
#P hidden newex 256 87 65 196617 r unmatched;
#P hidden newex 182 87 65 196617 r substrings;
#P hidden newex 84 87 87 196617 r backreferences;
#P hidden newex -1 87 76 196617 r substitutions;
#P comment 64 260 59 196617 Substrings;
#P comment 1 154 70 196617 Substitutions;
#P comment 81 311 103 196617 Pass Thru No Match;
#P hidden connect 15 0 16 0;
#P hidden connect 16 0 7 0;
#P hidden connect 3 0 7 0;
#P hidden connect 7 0 11 0;
#P hidden connect 16 0 8 0;
#P hidden connect 4 0 8 0;
#P hidden connect 8 0 12 0;
#P hidden connect 9 0 13 0;
#P hidden connect 16 0 9 0;
#P hidden connect 5 0 9 0;
#P hidden connect 10 0 14 0;
#P hidden connect 16 0 10 0;
#P hidden connect 6 0 10 0;
#P pop 1;
#P hidden newobj 88 374 41 196617 p show;
#P hidden comment 90 286 40 196617 CLEAR;
#P message 267 130 73 196617 substitute and;
#P window linecount 2;
#P message 248 385 233 196617 The group &amp doesn’t have a name. See their
&quot website at "http//:www.sucks.com" &don;
#P window linecount 1;
#P message 796 132 118 196617 re &(.*?)\\W|&(.*?).;
#P hidden newex 120 243 40 196617 s input;
#P newex 18 43 27 196617 t l b;
#P newex 18 21 40 196617 r input;
#P newex 60 100 65 196617 s unmatched;
#P newex 46 119 65 196617 s substrings;
#P newex 32 139 87 196617 s backreferences;
#P newex 18 159 76 196617 s substitutions;
#P newex 18 70 66 196617 regexp;
#P window linecount 2;
#P comment 88 67 100 196617 Control option click to see expression;
#P comment 278 51 100 196617 PROBLEMS WITH AMPERSAND;
#P window linecount 3;
#P comment 691 295 289 196617 Another & another is never enough. I want all
I want nothing , no in between … I’ll piss & my soul will be in it. I
want all I want nothing , no in between …;
#P window linecount 1;
#P comment 693 278 100 196617 Original;
#P window linecount 3;
#P comment 419 112 100 196617 At least no pass thru match at the same time;
#P connect 10 0 11 0;
#P connect 11 0 5 0;
#P connect 5 0 6 0;
#P hidden connect 21 0 20 0;
#P hidden connect 20 0 19 0;
#P connect 5 1 7 0;
#P connect 5 2 8 0;
#P connect 5 3 9 0;
#P hidden connect 11 1 18 0;
#P hidden connect 19 0 17 0;
#P hidden connect 18 0 17 0;
#P connect 33 0 12 0;
#P connect 32 0 12 0;
#P connect 31 0 12 0;
#P connect 30 0 12 0;
#P connect 29 0 12 0;
#P connect 28 0 12 0;
#P connect 27 0 12 0;
#P hidden connect 24 0 12 0;
#P hidden connect 23 0 12 0;
#P hidden connect 15 0 12 0;
#P hidden connect 14 0 12 0;
#P hidden connect 13 0 12 0;
#P connect 25 0 12 0;
#P connect 26 0 12 0;
#P connect 21 0 15 0;
#P connect 21 0 29 0;
#P window clipboard copycount 36;


November 22, 2006 | 7:43 pm

Note the coll is storing html text so ‘&’ gets changed to ‘&amp’

On 11/22/06, Dave Leith wrote:
>
> Original text is
>
> Another & another is never enough. I want all I want nothing, no in
> between … I’ll miss & my soul will be in it. I want all I want nothing, no
> in between …
>
> —————————————————————————————————————
>
> Coll stores as
>
> "Another &
> another is never enough. I want all I want nothing, no in between …
> I’ll miss &
> my soul will be in it. I want all I want nothing, no in between …"
>
> ——————————————————————————————————–
>
> How do I get regexp to substitute the ‘&’ with an ‘and’ ?
> I would like there to be no ‘unmatched’ string that shows up.
>
> Substitution like this……
> Another and another is never enough. I want all I want nothing, no in
> between … I’ll miss and my soul will be in it. I want all I want nothing,
> no in between …
>
>
> ——————————————————————————————————
> so far…………………..
>
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P comment 793 33 100 196617 NOPE!;
> #P comment 246 264 100 196617 Coll stores as;
> #P message 796 87 86 196617 re &([^&]*)\\W;
> #P message 796 107 139 196617 re &([^&]*)[^&]+\\w*\\W;
> #P message 796 186 118 196617 re &amp\\\;\\w*\\W;
> #P message 796 158 94 196617 re &amp|&([^&]*);
> #P message 345 130 66 196617 re &([^&]*);
> #B color 6;
> #P message 796 66 129 196617 re &(.*?)\\W|&([^&]*).;
> #P window linecount 3;
> #P message 247 283 392 196617 "Another &amp\;
> another is never enough. I want all I want nothing\, no in between …
> I’ll piss &amp\;
> my soul will be in it. I want all I want nothing\, no in between …";
> #P window linecount 1;
> #P message 248 441 137 196617 spcnet. … SPCNET.TV &gt\;;
> #P message 248 526 203 196617 I love MiMi pictures from scenery &amp\;;
> #P window linecount 2;
> #P message 248 473 254 196617 http://www.i love dmypet.com/view.asp?
> id=13483&amp\; preview=yes&amp\;;
> #P message 248 335 226 196617 The group &amp doesn’t have a name. See
> their &quot website at http//:www.sucks.com &don.;
> #P hidden comment 86 298 40 196617 _show_ window;
> #P window linecount 1;
> #P hidden newex 29 261 48 196617 loadbang;
> #P hidden message 29 283 29 196617 open;
> #P hidden newex 29 305 51 196617 pcontrol;
> #B color 5;
> #P button 88 322 33 0;
> #N vpatcher 1027 49 1622 488;
> #P origin -40 24;
> #P window setfont "Sans Serif" 9.;
> #P comment 21 218 79 196617 Backreferences;
> #P hidden message -1 53 14 196617 -;
> #P hidden inlet 0 31 15 0;
> #P message 187 310 577 196617 -;
> #P window linecount 3;
> #P message 137 257 443 196617 "&amp\;
> another is never enough. I want all I want nothing\, no in between …
> I’ll piss " "&amp\;
> my soul will be in it. I want all I want nothing\, no in between …";
> #P window linecount 2;
> #P message 110 215 432 196617 "amp\;
> my soul will be in it. I want all I want nothing\, no in between …";
> #P window linecount 1;
> #P message 68 153 492 196617 Another andand;
> #P hidden newex 256 118 62 196617 prepend set;
> #P hidden newex 182 118 62 196617 prepend set;
> #P hidden newex 84 118 62 196617 prepend set;
> #P hidden newex -1 118 62 196617 prepend set;
> #P hidden newex 256 87 65 196617 r unmatched;
> #P hidden newex 182 87 65 196617 r substrings;
> #P hidden newex 84 87 87 196617 r backreferences;
> #P hidden newex -1 87 76 196617 r substitutions;
> #P comment 64 260 59 196617 Substrings;
> #P comment 1 154 70 196617 Substitutions;
> #P comment 81 311 103 196617 Pass Thru No Match;
> #P hidden connect 15 0 16 0;
> #P hidden connect 16 0 7 0;
> #P hidden connect 3 0 7 0;
> #P hidden connect 7 0 11 0;
> #P hidden connect 16 0 8 0;
> #P hidden connect 4 0 8 0;
> #P hidden connect 8 0 12 0;
> #P hidden connect 9 0 13 0;
> #P hidden connect 16 0 9 0;
> #P hidden connect 5 0 9 0;
> #P hidden connect 10 0 14 0;
> #P hidden connect 16 0 10 0;
> #P hidden connect 6 0 10 0;
> #P pop 1;
> #P hidden newobj 88 374 41 196617 p show;
> #P hidden comment 90 286 40 196617 CLEAR;
> #P message 267 130 73 196617 substitute and;
> #P window linecount 2;
> #P message 248 385 233 196617 The group &amp doesn’t have a name. See
> their &quot website at "http//:www.sucks.com" &don;
> #P window linecount 1;
> #P message 796 132 118 196617 re &(.*?)\\W|&(.*?).;
> #P hidden newex 120 243 40 196617 s input;
> #P newex 18 43 27 196617 t l b;
> #P newex 18 21 40 196617 r input;
> #P newex 60 100 65 196617 s unmatched;
> #P newex 46 119 65 196617 s substrings;
> #P newex 32 139 87 196617 s backreferences;
> #P newex 18 159 76 196617 s substitutions;
> #P newex 18 70 66 196617 regexp;
> #P window linecount 2;
> #P comment 88 67 100 196617 Control option click to see expression;
> #P comment 278 51 100 196617 PROBLEMS WITH AMPERSAND;
> #P window linecount 3;
> #P comment 691 295 289 196617 Another & another is never enough. I want
> all I want nothing , no in between … I’ll piss & my soul will be in it. I
> want all I want nothing , no in between …;
> #P window linecount 1;
> #P comment 693 278 100 196617 Original;
> #P window linecount 3;
> #P comment 419 112 100 196617 At least no pass thru match at the same
> time;
> #P connect 10 0 11 0;
> #P connect 11 0 5 0;
> #P connect 5 0 6 0;
> #P hidden connect 21 0 20 0;
> #P hidden connect 20 0 19 0;
> #P connect 5 1 7 0;
> #P connect 5 2 8 0;
> #P connect 5 3 9 0;
> #P hidden connect 11 1 18 0;
> #P hidden connect 19 0 17 0;
> #P hidden connect 18 0 17 0;
> #P connect 33 0 12 0;
> #P connect 32 0 12 0;
> #P connect 31 0 12 0;
> #P connect 30 0 12 0;
> #P connect 29 0 12 0;
> #P connect 28 0 12 0;
> #P connect 27 0 12 0;
> #P hidden connect 24 0 12 0;
> #P hidden connect 23 0 12 0;
> #P hidden connect 15 0 12 0;
> #P hidden connect 14 0 12 0;
> #P hidden connect 13 0 12 0;
> #P connect 25 0 12 0;
> #P connect 26 0 12 0;
> #P connect 21 0 15 0;
> #P connect 21 0 29 0;
> #P window clipboard copycount 36;
>
>


December 2, 2006 | 10:02 am

I think your regexp’s are wrong – try passing "re &;", "substitute and ", and your message – that works for me.

max v2;
#N vpatcher 10 59 610 459;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 47 175 36 196617 print;
#P message 268 103 79 196617 substitute "and ";
#P newex 87 175 36 196617 print;
#P message 200 104 41 196617 re &\;;
#P window linecount 4;
#P message 47 37 317 196617 "Another &\;
another is never enough. I want all I want nothing\, no in between …
I’ll piss &\;
my soul will be in it. I want all I want nothing\, no in between …";
#P window linecount 1;
#P newex 47 129 78 196617 regexp;
#P connect 4 0 0 0;
#P connect 1 0 0 0;
#P fasten 2 0 0 0 205 124 52 124;
#P connect 0 0 5 0;
#P fasten 0 2 3 0 86 160 92 160;
#P pop;


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