1

I can I convert exactly this regex in c#:

Regex (@"\s*nameserver\s+(?<address>.*)")
Regex (@"\s*search\s+(?<domain>.*)")

to std::tr1::regex or to regex.h in C++? (Linux)

thanks!

3 Answers 3

1

I don't know the std::tr1::regex package, but if it is in fact based on boost::regex, then it should be trivial to translate these regexes:

"\\s*nameserver\\s+(?<address>.*)"
"\\s*search\\s+(?<domain>.*)"

You need to escape the backslashes when constructing the string that contains the regex. Apart from that, those two regexes don't use any features that boost::regex's Perl-compatible engine can't handle.

Sign up to request clarification or add additional context in comments.

2 Comments

IIRC they are using the boost package for regex boost.org/doc/libs/1_45_0/libs/regex/doc/html/index.html
@Uwe Keim: Thanks for the information! Well in that case, they (at least when using the Perl compatible engine) should even be able to handle named capturing groups. So probably it's the need to escape the backslashes...
0

std::tr1::regex in GCC is incompelete. std::regex have bugs.

Consider boost::regex.

1 Comment

I can't use boost, do you have any other suggestion?
0

For what it's worth, if you are using, g++, you are out of luck: Regular expressions are currently not implemented in g++/tr1:

http://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.tr1

Comments

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.