// Copyright Contributors to the Open Shading Language project.
// SPDX-License-Identifier: BSD-3-Clause
// https://github.com/AcademySoftwareFoundation/OpenShadingLanguage

shader u_subj_v_pattern_vra (output vector cout = 0)
{
    string u_subj = "electric blue";
    string v_pat1 = concat(format("%g", P[0]), "ham");
    string v_pat2 = concat(format("%g", P[0]), "ue");
    string v_pat3 = concat(format("%g", P[0]), "$el");
    string v_pat4 = concat(format("%g", P[0]), "el[a-b]");
    string v_pat5 = concat(format("%g", P[0]), ".*tric");
    string v_pat6 = concat(format("%g", P[0]), "blue");

    string v_pat7 = format("%g", P[0]);
    v_pat7 = "e";
 
    int results[3] = {int(P[0]), int(P[0]), int(P[0])};
    int results_match[3] = {int(P[0]), int(P[0]), int(P[0])};
    int a = -1;
    int b = -1;
    int c = -1;
    int d = -1;
    int e = -1;
    int f = -1;
    int g = -1;
    int h = -1;
    int f_match = -1;

    a =  regex_match (u_subj, v_pat1);         // should not match
    b =  regex_match (u_subj, v_pat2);  // should match
    c =  regex_match (u_subj, v_pat3);
    d =  regex_match (u_subj, v_pat4);
    e =  regex_match (u_subj, v_pat5);       // should match
 
    f =  regex_search (u_subj,results, v_pat6);// will not match
    f_match = regex_match(u_subj, results_match, v_pat7);

    for (int i = 0; i < 3; ++i) {
        g += results[i];
        h += results_match[i];
    }

    if( (a >=0) && (b>=0) && (c>=0) && (d>=0) && (e>=0) && 
        (f>=0) && (f_match>=0) && (g>=0) && (h>=0)) {
        cout = vector(a+b/u, (c+d+h/v+u), (e*f+g/v*u));
    }  
}
