davej Posted April 4, 2011 Share Posted April 4, 2011 In the Regex examples such as here;http://w3schools.com/jsref/tryit.asp?filen..._regexp_charsetWhat is the var type of patt1?With JS being loosely-typed I don't quite know what is what.Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted April 4, 2011 Share Posted April 4, 2011 It's an implicitly-created RegExp object. You could also do this:var patt1 = new RegExp('[a-h]', 'g');http://www.w3schools.com/jsref/jsref_obj_regexp.asp Link to comment Share on other sites More sharing options...
jeffman Posted April 4, 2011 Share Posted April 4, 2011 Also called a regex literal. Perl uses them all over the place. They are very common when the expression does not need to be constructed from variable data. The RegExp constructor exists for when you need to do that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.