Home > database >  Regular expression missing the pattern match
Regular expression missing the pattern match

Time:11-16

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

CodePudding user response:

[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.

  • Related