Help withSprintf Regexp and quotation marks


    Nov 06 2006 | 12:50 am
    I've been going in circles for a few days now.
    I need to be able to assemble (with variables) a 3 word phrase. For regexp
    to recognize the complete 3 word phrase the phrase needs to be enclosed in
    quotation marks. This works correctly if the expression is typed into the
    regexp object ....but I can't seem to find the right combination of sprintf,
    tosymbol to create this. I've enclosed a sample patch below. Thanks

    • Nov 06 2006 | 5:50 am
      Ok this seems closer but still doesn't work. Somebody???
      ---------------------------------------------------------------------------------------
      On 11/5/06, Dave Leith wrote:
      >
      > I've been going in circles for a few days now.
      >
      > I need to be able to assemble (with variables) a 3 word phrase. For regexp
      > to recognize the complete 3 word phrase the phrase needs to be enclosed in
      > quotation marks. This works correctly if the expression is typed into the
      > regexp object ....but I can't seem to find the right combination of sprintf,
      > tosymbol to create this. I've enclosed a sample patch below. Thanks
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P newex 410 236 51 196617 tosymbol;
      > #P newex 292 383 122 196617 regexp @re "I want you";
      > #P newex 194 372 41 196617 print 2;
      > #P message 289 265 144 196617 I want you to get quote marks;
      > #P newex 194 337 66 196617 regexp;
      > #P button 67 29 15 0;
      > #P message 226 52 32 196617 want;
      > #P newex 226 80 73 196617 v searchTerm;
      > #P newex 74 323 41 196617 print 0;
      > #P message 224 118 24 196617 you;
      > #P newex 224 146 79 196617 v searchTerm2;
      > #P window setfont "Sans Serif" 12.;
      > #P newex 70 262 152 196620 sprintf @re "%sI %s %s";
      > #P window setfont "Sans Serif" 9.;
      > #P newex 433 55 48 196617 loadbang;
      > #P newex 167 219 79 196617 v searchTerm2;
      > #P newex 65 57 53 196617 t b b b b;
      > #P newex 78 219 73 196617 v searchTerm;
      > #P window linecount 3;
      > #P comment 277 332 217 196617 I need regexp to recieve the value @re "I
      > want you" to recognize the complete phrase , not single letters or words;
      > #P window linecount 2;
      > #P comment 422 379 100 196617 This works correctly;
      > #P connect 5 0 8 0;
      > #P connect 5 0 11 0;
      > #P connect 12 0 3 0;
      > #P connect 3 0 6 0;
      > #P connect 6 0 9 0;
      > #P connect 3 1 2 0;
      > #P connect 2 0 6 1;
      > #P connect 3 2 4 0;
      > #P connect 6 0 13 0;
      > #P connect 14 0 13 0;
      > #P connect 13 0 15 0;
      > #P connect 4 0 6 2;
      > #P connect 11 0 10 0;
      > #P connect 8 0 7 0;
      > #P window clipboard copycount 18;
      >
      >
    • Nov 06 2006 | 1:25 pm
      05/11/06, kl. 6:50 +0100 , skrev Dave Leith:
      >Ok this seems closer but still doesn't work. Somebody???
      >> I've been going in circles for a few days now.
      >>
      >> I need to be able to assemble (with variables) a 3 word phrase. For regexp
      >> to recognize the complete 3 word phrase the phrase needs to be enclosed in
      >> quotation marks. This works correctly if the expression is typed into the
      >> regexp object ....but I can't seem to find the right combination of
      sprintf,
      >> tosymbol to create this. I've enclosed a sample patch below. Thanks
      Something like this?
      J
    • Nov 06 2006 | 4:08 pm
      Thanks that does seem to format the expression correctly (and a lot more
      neatly) but for some reason regexp doesn't like it either - seems to ignore
      it too just like my mine.
      On 11/6/06, Jakob Riis wrote:
      >
      > 05/11/06, kl. 6:50 +0100 , skrev Dave Leith:
      >
      > >Ok this seems closer but still doesn't work. Somebody???
      >
      > >> I've been going in circles for a few days now.
      > >>
      > >> I need to be able to assemble (with variables) a 3 word phrase. For
      > regexp
      > >> to recognize the complete 3 word phrase the phrase needs to be enclosed
      > in
      > >> quotation marks. This works correctly if the expression is typed into
      > the
      > >> regexp object ....but I can't seem to find the right combination of
      > sprintf,
      > >> tosymbol to create this. I've enclosed a sample patch below. Thanks
      >
      > Something like this?
      > J
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P newex 44 269 30 196617 t b s;
      > #P newex 44 319 51 196617 tosymbol;
      > #P button 44 219 15 0;
      > #P newex 126 244 79 196617 v searchTerm2;
      > #P newex 44 244 73 196617 v searchTerm;
      > #P newex 44 369 62 196617 prepend set;
      > #P message 44 394 139 196617 @re "I want you";
      > #P newex 44 294 52 196617 pack I s s;
      > #P newex 44 344 89 196617 sprintf @re "%s";
      > #P comment 394 304 100 196617 2 CLICK Here;
      > #P newex 499 439 41 196617 print 6;
      > #P newex 458 439 41 196617 print 5;
      > #P newex 418 439 41 196617 print 4;
      > #P newex 368 439 47 196617 print 33;
      > #P newex 327 438 41 196617 print 3;
      > #P newex 418 394 122 196617 regexp @re "I want you";
      > #P newex 286 438 41 196617 print 2;
      > #P message 392 323 144 196617 I want you to get quote marks;
      > #P newex 297 395 66 196617 regexp;
      > #P message 40 48 32 196617 want;
      > #P newex 40 76 73 196617 v searchTerm;
      > #P message 38 114 24 196617 you;
      > #P newex 38 142 79 196617 v searchTerm2;
      > #P newex 204 58 48 196617 loadbang;
      > #P window linecount 3;
      > #P comment 424 348 217 196617 I need regexp to recieve the value @re "I
      > want
      > you" to recognize the complete phrase , not single letters or words;
      > #P window linecount 2;
      > #P comment 548 415 100 196617 This works correctly;
      > #P connect 17 0 20 0;
      > #P connect 17 0 10 0;
      > #P connect 8 0 7 0;
      > #P connect 8 0 10 0;
      > #P connect 23 0 21 0;
      > #P fasten 23 0 22 0 49 239 131 239;
      > #P connect 2 0 4 0;
      > #P connect 2 0 6 0;
      > #P connect 21 0 25 0;
      > #P connect 25 1 18 1;
      > #P connect 25 0 18 0;
      > #P connect 22 0 18 2;
      > #P connect 18 0 24 0;
      > #P connect 24 0 17 0;
      > #P connect 20 0 19 0;
      > #P connect 10 2 15 0;
      > #P connect 10 1 14 0;
      > #P connect 10 0 13 0;
      > #P connect 7 2 12 0;
      > #P connect 6 0 5 0;
      > #P connect 7 1 11 0;
      > #P connect 4 0 3 0;
      > #P connect 7 0 9 0;
      > #P window clipboard copycount 26;
      >
      >
      >
    • Nov 07 2006 | 12:11 am
      06/11/06, kl. 17:08 +0100 , skrev Dave Leith:
      >Thanks that does seem to format the expression correctly (and a lot more
      >neatly) but for some reason regexp doesn't like it either - seems to ignore
      >it too just like my mine.
      >
      now?
    • Nov 07 2006 | 1:54 am
      Well not quite...very bizarre. Your code was good. The problem seems to be
      an inconsistency here with regexp. The one on the right has the @re typed
      into the object and works fine, The one on the left which is accepting a
      vthe sprint variable string doesn't work with the @re ... it needs to be
      just the re xxxxxxxx
      I've included a working example. Thanks so much for your help on this.
      On 11/6/06, Jakob Riis wrote:
      >
      > 06/11/06, kl. 17:08 +0100 , skrev Dave Leith:
      >
      > >Thanks that does seem to format the expression correctly (and a lot more
      > >neatly) but for some reason regexp doesn't like it either - seems to
      > ignore
      > >it too just like my mine.
      > >
      >
      > now?
      >
      >
      > #P window setfont "Sans Serif" 9.;
      > #P window linecount 1;
      > #P newex 104 94 53 196617 t b b b b;
      > #P newex 104 329 30 196617 t b s;
      > #P newex 104 379 51 196617 tosymbol;
      > #P button 104 49 15 0;
      > #P newex 186 304 79 196617 v searchTerm2;
      > #P newex 104 304 73 196617 v searchTerm;
      > #P newex 104 429 62 196617 prepend set;
      > #P window linecount 0;
      > #P message 104 454 103 196617;
      > #P window linecount 1;
      > #P newex 104 354 52 196617 pack I s s;
      > #P newex 104 404 89 196617 sprintf @re "%s";
      > #P comment 454 364 100 196617 2 CLICK Here;
      > #P newex 559 499 41 196617 print 6;
      > #P newex 518 499 41 196617 print 5;
      > #P newex 478 499 41 196617 print 4;
      > #P newex 428 499 47 196617 print 33;
      > #P newex 387 498 41 196617 print 3;
      > #P newex 478 454 122 196617 regexp @re "I want you";
      > #P newex 346 498 41 196617 print 2;
      > #P message 452 383 144 196617 I want you to get quote marks;
      > #P newex 357 455 87 196617 regexp @re want;
      > #P message 345 179 32 196617 want;
      > #P newex 345 207 73 196617 v searchTerm;
      > #P message 241 179 24 196617 you;
      > #P newex 241 207 79 196617 v searchTerm2;
      > #P window linecount 3;
      > #P comment 484 408 217 196617 I need regexp to recieve the value @re "I
      > want
      > you" to recognize the complete phrase , not single letters or words;
      > #P window linecount 2;
      > #P comment 608 475 100 196617 This works correctly;
      > #P connect 22 0 25 0;
      > #P connect 25 0 20 0;
      > #P connect 25 1 21 0;
      > #P connect 25 2 3 0;
      > #P connect 25 3 5 0;
      > #P connect 9 2 14 0;
      > #P connect 9 1 13 0;
      > #P connect 9 0 12 0;
      > #P connect 7 0 6 0;
      > #P connect 7 0 9 0;
      > #P connect 16 0 19 0;
      > #P connect 16 0 6 0;
      > #P connect 16 0 9 0;
      > #P connect 6 2 11 0;
      > #P connect 6 1 10 0;
      > #P connect 6 0 8 0;
      > #P connect 21 0 17 2;
      > #P connect 24 1 17 1;
      > #P connect 19 0 18 0;
      > #P connect 23 0 16 0;
      > #P connect 17 0 23 0;
      > #P connect 24 0 17 0;
      > #P connect 20 0 24 0;
      > #P connect 5 0 4 0;
      > #P connect 3 0 2 0;
      > #P window clipboard copycount 26;
      >
      >
      >