The code for a literal regular expression is pretty basic; just define a variable whose value is encapsulated within single forward slashes:
var myRegexp = /www/;
This is a regular expression in its most basic form, and to go with it, we can make use of its most basic method; the .test method:
var myRegxp = /www/;
This would simply write 'true' to the page. There are a few other, very basic things we could do with this using flags. The regular expression in the above example is case sensitive, so changing the www in the first line to WWW would output 'false' instead. To make the regular expression case insensitive, you just add i directly after the initial declaration:
var myRegxp = /WWW/i;
which again, writes 'true'. Other flags that may be used are the g or global flag, and the m or multi-line flag.