Click here to Skip to main content
15,742,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i can't #include<regex.h> (regular Regular expressions)in my c program. I very new about programming, therefore i don,t know how to add file(or module i don't sure what's it called) in my c in my library.

What I have tried:

I try to download so thing (that i can't remember) but when it don't working out i just deleted it, so basically,I didn't do anything.
Updated 24-May-22 9:58am
Richard MacCutchan 24-May-22 15:53pm    
Which compiler and framework are you using?

1 solution

If you're using Linux of MacOS, then regex.h should be installed as part of the libc development packages. Don't forget to #include <sys/types> before you #include <regex.h>. But I'm guessing you're using Windows and Visual Studio. In which case the bad news is that MS does not provide regex routines, but maybe you could move to C++ and use the C++ regular expression routines which are part of the C++ standard as of C++-11.Regular expressions library -[^]

If you are just starting out, then regex might not be a good fit for what you're trying to do. If all you want is some string handling the str*() functions may provide you with all you need (eg. strchr(), strspn(), strstr(), etc).

If you are intent on doing work with regex, and you are using Visual Studio, the you'll need to install a regex package. Doing a google search turned up this Pcre for Windows[^] Note that this is Perl regular expressions, not POSIX. PCRE and Posix are similar, but not the same. If you're doing complex regular expressions, you may need to read some PCRE documentation: PCRE - Perl Compatible Regular Expressions[^]
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900