I want to extract multiple GLSL sources from a single file, separated with a header. I wrote this small regex, to do this for me:
(?:\n|^)-- (\w*)\.?(\d\d\d)?\.(\w\w\w?)\r?\n([\s\S\r\n]*?)(?=\n--|$)
Runs on a source like this:
-- passthrough.VS
in vec4 position;
void main(){
gl_Position = position;
}
-- mvp.VS
layout (location=0) in vec3 position;
uniform mat4 model;
#include "engine/shaders/vp_include.glsl"
void main () {
gl_Position = proj * view * model * vec4 (position, 1.0);
}
The capture group ([\s\S\r\n]*?)
is supposed to match the body of the shader. I included \r\n
because of Regex Working on regexr but not Visual Studio.
The expected output (and the code to run) is here: http://coliru.stacked-crooked.com/a/a890795f0c438a0b, compiled with gcc (regex101.com's engine also gives the expected output).
My problem is with Visual Studio 2015, where this last capture simply matches an empty string (the other captures work).
Am I missing something? Is this a bug in the VS regex implementation?