Delirium tremens
Delirium tremens

Reputation: 4739

test1 alert appears, test2 alert doesn't - invalid regex between them?

alert('test1');
var re = new RegExp("(http://(?:[A-Za-z0-9-]+\\.)?[A-Za-z0-9-]+\\.[A-Za-z0-9-]+/?)", "si");
alert('test2');

Why is this happening? How to solve this problem?

Upvotes: 1

Views: 108

Answers (1)

Andy E
Andy E

Reputation: 344575

The "s" is the problem, it's not a valid modifier for javascript regular expressions. The only valid modifiers are /g (global) /i (case-insensitive) and /m (multi-line).

Upvotes: 4

Related Questions