Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using the posix fnmatch to compare to an empty string

Posted on 2013-01-21
2
Medium Priority
?
337 Views
Last Modified: 2013-11-13
I have a lot of code that uses the fnmatch C function to match strings against patterns.

From time to time I want to match against empty strings, but the wildcard * relates to one or more characters, not zero characters.

I was sure you could achieve a pattern to match all blank strings with

!(?*)

meaning any string that is not one character or more in length, but this does not match.

What is the "right" way to get a match from:

fnmatch(..., "", 0)

where ... is the pattern?
0
Comment
Question by:gazillabyte
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 450 total points
ID: 38803689
fnmatch("", "", 0)
0
 

Author Comment

by:gazillabyte
ID: 38804077
Cheers.

I had a wrapper around fnmatch which checked the length of the pattern and the string and returned false if they were both empty. It must have seemed like a good idea at the time ;-)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Make the most of your online learning experience.
What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
Progress
Introduction to Processes

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question