Regular expressions

1
2
3
var groove = /tupa/;
var groove = new RegExp("tupa");
// are the same

RegExp flags:

  • i makes the RegExp case-insensitive
  • g matches all instances. Default is the first one.
  • m match across multiline, textarea for example

    1
    2
    
    var groove = /tupa/ig
    var groove = new RegExp("tupa","ig")
    

Examples

1
2
3
4
5
6
var groove = /()/;
console.log(groove.test('()order')); //

var groove = /deep/i
console.log(groove.test('Deep'));