0

I made a program on Linux, but now I want to make it compatible with Windows. So I compiled my libraries in Windows, created a Code::Blocks project, and starting adapting some functions and variables that don't suit to Windows.

But there is a function that I don't understand why it doesn't work, regex_replace(). #include doesn't give an error, and regex_match neither. Here is my function:

string str = "hey guys";
str = regex_replace(string str, regex("guys"), "girls");

And 'str' is now "hey girls".

But when I compile on Windows, it gives me this error: "no matching function for call to 'regex_replace'". I searched a little bit, but I didn't find anything interesting.

So what should I do? Thank you!

4
  • Probably a problem of compiler / standard library versions. Which compiler (and version) are you using on both Linux and Windows? Commented Feb 21, 2013 at 17:07
  • did you #include <regexp>? did you try std::regex_replace? Commented Feb 21, 2013 at 17:12
  • 1
    @aleguna - #include <regex>, not regexp. Commented Feb 21, 2013 at 17:25
  • On Linux (in fact MacOS), I had used XCode. On Windows, I'm using Code::Blocks with MinGW. I included <regex> and tried std::regex_replace ;-) Commented Feb 21, 2013 at 17:29

1 Answer 1

1

That's a code problem, not a windows problem. Your code compiles neither on Linux, nor on Windows:

str = regex_replace(string str, regex("guys"), "girls");
                    ^^^^^^
                    not allowed there
Sign up to request clarification or add additional context in comments.

1 Comment

Ok, this is something I didn't know. I tried with str.c_str(), but it didn't work too. What type should I put? Notice that it worked on MacOS ;=)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.