From OpenSCADAWiki
Jump to: navigation, search

Object functions:

  • Array exec( string val ); — calls match for string val. Returns found sub-string (0) and sub-expressions (>0) in the array. Sets attribute "index" of the array to the matched substring position. Sets the attribute "input" of the array to the source string.
    var re = new RegExp("(\\d\\d)[-/](\\d\\d)[-/](\\d\\d(?:\\d\\d)?)","");
    var rez = re.exec("12/30/1969");
    var month = rez[1];
    var day = rez[2];
    var year = rez[3];
    
  • bool test( string val ); — returns "true" for the match sub-string in val.
    var re = new RegExp("(\\d\\d)[-/](\\d\\d)[-/](\\d\\d(?:\\d\\d)?)","");
    var OK = re.test("12/30/1969");