I want to validate a string against legal characters using standard C. Is there a standard functionality? As far as I can see, GNU Lib C's regex lib is not available in VC++. What do you suggest for implementing such a simple task. I don't want to include PCRE library dependency. I'd prefer a simpler implementation.
How to validate a string against legal characters in standard C?
568 views Asked by AudioBubble At
2
You can check if a string contains any character from a given set of characters with strcspn.
Edit: as suggested by Inshalla and maykeye, strspn, wcsspn might be more appropriate for your task.
You would use
strspn
like so: