regexp and sprintf

Dec 28, 2010 at 12:45pm

regexp and sprintf

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 !

A patch is better than a 1000 words…

– Pasted Max Patch, click to expand. –

happy new year !

#54133
Dec 28, 2010 at 1:19pm

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

– Pasted Max Patch, click to expand. –
#194772
Dec 28, 2010 at 1:42pm

Forgot about the symout, thanks very much !

#194773
Dec 28, 2010 at 2:21pm

Surprisingly, it doesn’t work !

See the new patch :

– Pasted Max Patch, click to expand. –
#194774
Dec 28, 2010 at 3:33pm

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…)

Can anyone explain ? See patch…

– Pasted Max Patch, click to expand. –
#194775
Dec 28, 2010 at 5:24pm

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.

#194776
Dec 28, 2010 at 9:33pm

I got it now, thanks to the regexp masters !

#194777

You must be logged in to reply to this topic.