Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Regular expression missing the pattern match

I am trying to match a pattern with my input using regular expression .
I am trying to match the following string

00010_mesh_fbx_low_pileOfStoneAtWonwonsaTemple.fbx

using the following regular expression

std::regex("^[0-9]+_mesh_fbx_low_[a-z][A-Z][0-9].(?:fbx|glb|obj)"))

But I do not get a match for the input string

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

[a-z][A-Z][0-9]. matches a sequence of four chars: a lowercase ASCII letter, then an uppercase ASCII letter, then an ASCII digit and then any char other than line break chars.

You can fix your regex by using

std::regex(R"(^[0-9]+_mesh_fbx_low_[a-zA-Z0-9]+\.(?:fbx|glb|obj))")
std::regex(R"(^[0-9]+_mesh_fbx_low_\w+\.(?:fbx|glb|obj))")

where [a-zA-Z0-9]+ matches one or more ASCII alphanumeric chars, or \w+ that matches one or more ASCII alphanumeric or underscore chars.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading