RegEx Is Not Working As It Should
I have following JS regex which breaks the code and not working as it should.
var loginFailedRegex = /https:\/\/encore.lsbu.ac.uk\/iii\/cas\/login;jsessionid=[a-z0-9]*?service=https%3A%2F%2Flispac.lsbu.ac.uk%3A443%2Fpatroninfo~S1%2FIIITICKET/i;
if (loginFailedRegex.text(decodeURI(loc))) {
zoomPagePortion(100, 100);
}
The loginFailedRegex has only [a-z0-9]* as regex and o开发者_开发知识库ther whole string is static.
I think the regex problem is here
[a-z0-9]*?
you should probably have
[a-z0-9]*\?
Assuming that ?
is a literal in the URL that you are looking for you need to escape it in your regex.
Also you need to change text
to test
assuming that is not just a typo in your post.
var loginFailedRegex = /https:\/\/encore.lsbu.ac.uk\/iii\/cas\/login;jsessionid=[a-z0-9]*\?service=https%3A%2F%2Flispac.lsbu.ac.uk%3A443%2Fpatroninfo~S1%2FIIITICKET/i;
if (loginFailedRegex.test(decodeURI(loc))) {
zoomPagePortion(100, 100);
}
Here is a test page to verify
http://jsfiddle.net/cordsen/uVnZz/
精彩评论