By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

string comparison and wildcards

100+
P: 553
Hi

I have a string comparison code from VB.
While (Not ((myString Like "??????") And (myString Like "00*")))

All i am wondering is if we can do the similar thing in C/C++ i.e
using 'Like' keyword and doing wildcards like in above example?
Aug 14 '07 #1
Share this Question
Share on Google+
3 Replies


sicarie
Expert Mod 2.5K+
P: 4,677
Hi

I have a string comparison code from VB.
While (Not ((myString Like "??????") And (myString Like "00*")))

All i am wondering is if we can do the similar thing in C/C++ i.e
using 'Like' keyword and doing wildcards like in above example?
There are a few different ways to do it in C/C++ - using a regular expression, or using string methods. It depends on what you want to match and how many times you want to match it. I would recommend looking into the string methods or Boost's Regex library (I'm sure there are others, that's just the first that comes to mind). And if you post more about what you are trying to do (how specific a match you need, how many times you need that specific a match, etc...), we can probably point you to one of those specifically - or maybe even something else entirely (if someone else sees another method I didn't put).
Aug 14 '07 #2

100+
P: 553
Hi

I have used those string functions in past. I dont understand if any of these can be used to do a wildcard search.

I have no specific comparison but i was wondering if something is available in C/C++ same as 'Like' Operator in VB and SQL. ?

i know if i have a specific coomparison, i would be able to put many functions together to get the result but this would be alot of work whereas 'Like' does all


There are a few different ways to do it in C/C++ - using a regular expression, or using string methods. It depends on what you want to match and how many times you want to match it. I would recommend looking into the string methods or Boost's Regex library (I'm sure there are others, that's just the first that comes to mind). And if you post more about what you are trying to do (how specific a match you need, how many times you need that specific a match, etc...), we can probably point you to one of those specifically - or maybe even something else entirely (if someone else sees another method I didn't put).
Aug 14 '07 #3

sicarie
Expert Mod 2.5K+
P: 4,677
Hi

I have used those string functions in past. I dont understand if any of these can be used to do a wildcard search.

I have no specific comparison but i was wondering if something is available in C/C++ same as 'Like' Operator in VB and SQL. ?

i know if i have a specific coomparison, i would be able to put many functions together to get the result but this would be alot of work whereas 'Like' does all
A regex can do a wildcard search using either the * as the all or the . as the any single tokens. Looking at the links might help.
Aug 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.