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++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
Developer technologies | C#
Developer technologies | C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
0 comments No comments
{count} votes

Answer accepted by question author
  1. Viorel 125.7K 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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.