1

I got the following regular expression from config.js file in MEAN.JS framework

var urlRegex = new RegExp('^(?:[a-z]+:)?\/\/', 'i');

But I can't understand the regular expression. Can someone explain it or give me some matching examples?

eeandrew
  • 79
  • 2
  • 9
  • Mostly I'm confused by `?:`. I find some explanation [here](http://stackoverflow.com/questions/3512471/non-capturing-group) – eeandrew Oct 15 '14 at 12:43

1 Answers1

1
^(?:[a-z]+:)?\/\/

Says from start there can be strings followed by:followd by//. strings is optional.Look at the demo.

http://regex101.com/r/dZ1vT6/19

asdsadas:// ===>will match

// ====>will match

213123dasdsad:// ====>will not match at the start is from number

vks
  • 63,206
  • 9
  • 78
  • 110