How to use verbatin String in managed c++

checkingrandom 226 Reputation points
2023-01-03T08:12:34.25+00:00

I'm working with c# regex and got the expected result

var match = Regex.Match(sub, @"\w{5}-\w{5}-\w{5}-\w{5}-\w{5}");

So now I'm working with the same code with managed c++, now Im getting error in Regex.Match().

Match m = Regex::Match(number[i], "\w{5} - \w{5} - \w{5} - \w{5} - \w{5}");

but I'm getting the following error "no suitable user-defined conversion from "System::Text::RegularExpressions::Match ^" to "System::Text::RegularExpressions::Match" exists"

I also used raw string for the regex pattern, still the issue is resolved

Match m = Regex::Match(number[i], R"~(\w{5} - \w{5} - \w{5} - \w{5} - \w{5})~");

Developer technologies C++
Developer technologies C#
0 comments No comments
{count} votes

Accepted answer
  1. Viorel 122.5K Reputation points
    2023-01-03T09:03:12.4+00:00

    Try:

    Match ^m = Regex::Match( number[i], R"(\w{5}-\w{5}-\w{5}-\w{5}-\w{5})" );

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.