regexp and sprintf

nnimar's icon

Hi list,

I'm having trouble to format a message for regexp. I use jit.str.regexp to search for an exact word in a dictionary using the \b \b tags but I can't format it using sprintf as it get rids of the \ characters. I have also tried jasch's strcat but it gives me a symbol and once I want to remove the symbol I not only loose the "" but also the \ tags. Help appreciated !

Max Patch
Copy patch and select New From Clipboard in Max.

A patch is better than a 1000 words...

happy new year !

Luke Hall's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Double your escaping slashes and do it in two parts like this and you should be OK:

nnimar's icon

Forgot about the symout, thanks very much !

nnimar's icon

Surprisingly, it doesn't work !

Max Patch
Copy patch and select New From Clipboard in Max.

See the new patch :

nnimar's icon

More surprises ! The symout doesn't work in this situation, even if the message display looks correct. By using with , it works (even if the message display doesn't look correct...)

Max Patch
Copy patch and select New From Clipboard in Max.

Can anyone explain ? See patch...

Emmanuel Jourdan's icon

If you use sprintf symout \\b%s\\b what you passe to the regexp object is \bessai\b. If you use sprintf \\b%s\\b, the string output by sprintf is bessaib. The correct approach is the sprintf symout \b%s\b.

nnimar's icon

I got it now, thanks to the regexp masters !