How to use verbatin String in managed c++

Hari Pranesh 166 Reputation points

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})~");

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.
6,960 questions
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.
2,625 questions
No comments
{count} votes

Accepted answer
  1. Viorel 82,661 Reputation points


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

    No comments

0 additional answers

Sort by: Most helpful