RegEx in Angular 2 Form Validators producing different results when argument is a String vs a RegExp class
问题 I'm attempting to validate a basic form element using Angular 2 Form Validators, and the RegEx I'm placing in to Validators.pattern() to match a valid URL is matching patterns that theoretically aren't valid when the argument is a String data type. // example.component.ts this.exampleForm = fb.group({ // The patterns below will match most URL structures, and are exactly the same const reg = '^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$'; const patt = new RegExp(/^(https?:\/\