Combining Variables

Posted by DB on Tue 05 Mar 2019 02:18 AM — 5 posts, 18,565 views.

#0
Apologies in advance for the newbie question! Congrats on the Regexp library it is really useful!

My problem is if I match a message in quotes like ms.Match("63 100") my code works perfectly.

But I'd like to declare a variable in the beginning of the code so I don't need to change the values in the loop.

In the beginning of my code I'm declaring a variable like this:
char address = 63;

Then in the loop I want to match something like:
ms.Match (address, "100");

But as you know it does not work, I can't seem to find the right meta-character formatting to make it work.

Any suggestions please?
Amended on Tue 05 Mar 2019 02:48 AM by DB
Australia Forum Administrator #1

Use sprintf to make the thing you want to match on, and then pass that string to ms.Match.

#2
Thank you!

But then would I be creating a buffer with just two characters? Am I missing something?
Amended on Tue 05 Mar 2019 11:20 AM by DB
Australia Forum Administrator #3

No, the buffer would have in it: 63 100

That’s what you want to match on isn’t it? In any case can’t use you strstr if you just want to find if one string is inside another?

#4
Just because I didn’t know you could do that! Newbieism is a serious condition but I’m treating it! : )

Thanks Nick!