chriskchan
asked on
What is the largest regular expression size?
Say you declare a regular expression like:
var regMatch = new RegExp(sString);
What is the largest size that sString can be? If I have a search pattern that is 2855 characters long, i get an "java.lang.ArrayIndexOutOf BoundsExce ption: 20" error. Is there a limit? And is there a way to get around it?
Thanks,
Chris
var regMatch = new RegExp(sString);
What is the largest size that sString can be? If I have a search pattern that is 2855 characters long, i get an "java.lang.ArrayIndexOutOf
Thanks,
Chris
ASKER
Hi Zyloch,
The sString that I am putting in looks something like this "^1FB.U62E.4|^1FB.U62K.4|^ 1FB.U63E.4 |^1FB.U63K .4|^1FB.U6 3W.4|^1FB. U64E.4|^1F B.U64K.4" but it goes on for a long time. It is overflowing right at the line for declaring the regexp.
Chris
The sString that I am putting in looks something like this "^1FB.U62E.4|^1FB.U62K.4|^
Chris
Doesn't seem to be a limit. I took your line and copied it over and over again until the string was a bit over 100,000 and while IE took its sweet time loading, it still didn't produce an error. Also, ArrayIndexOufOfBoundsExcep tions isn't an error usually produced in Javascript. #1, javasript errors don't have java.lang. Second of all, Javascript doesn't produce ArrayIndexOutOfBoundsExcep tions like Java does.
You can try putting / and / at the beginning and end of sString but shouldn't make much difference.
It may be in the rest of your code. Can you post that?
Regards...
You can try putting / and / at the beginning and end of sString but shouldn't make much difference.
It may be in the rest of your code. Can you post that?
Regards...
Your regular expression looks remarkable inefficient.
It seems to be:
^1FB.U6[some digit][some letters].4
What possible values are you looking for for some digit or some letter?
It seems to be:
^1FB.U6[some digit][some letters].4
What possible values are you looking for for some digit or some letter?
ASKER
Whoops, you're right, it's failing on the next line when it's doing the regular expression test. So I'm getting the outofbounds exception on:
bRetVal = !regMatch.test(sVIN);
where sVIN is a string "1FMZU62K14ZA67457".
The full sString that makes up the regMatch regular expression is "^1FB.U62E.4|^1FB.U62K.4|^ 1FB.U63E.4 |^1FB.U63K .4|^1FB.U6 3W.4|^1FB. U64E.4|^1F B.U64K.4|^ 1FB.U64W.4 |^1FB.U65E .4|^1FB.U6 5K.4|^1FB. U65W.4|^1F B.U71E.4|^ 1FB.U72E.4 |^1FB.U72K .4|^1FB.U7 3E.4|^1FB. U73K.4|^1F B.U73W.4|^ 1FB.U74E.4 |^1FB.U74K .4|^1FB.U7 4W.4|^1FB. U75E.4|^1F B.U75K.4|^ 1FB.U75W.4 |^1FB.U82E .4|^1FB.U8 2K.4|^1FB. U83E.4|^1F B.U83K.4|^ 1FB.U83W.4 |^1FB.U84E .4|^1FB.U8 4K.4|^1FB. U84W.4|^1F B.U85E.4|^ 1FB.U85K.4 |^1FB.U85W .4|^1FD.U6 2E.4|^1FD. U62K.4|^1F D.U63E.4|^ 1FD.U63K.4 |^1FD.U63W .4|^1FD.U6 4E.4|^1FD. U64K.4|^1F D.U64W.4|^ 1FD.U65E.4 |^1FD.U65K .4|^1FD.U6 5W.4|^1FD. U71E.4|^1F D.U72E.4|^ 1FD.U72K.4 |^1FD.U73E .4|^1FD.U7 3K.4|^1FD. U73W.4|^1F D.U74E.4|^ 1FD.U74K.4 |^1FD.U74W .4|^1FD.U7 5E.4|^1FD. U75K.4|^1F D.U75W.4|^ 1FD.U82E.4 |^1FD.U82K .4|^1FD.U8 3E.4|^1FD. U83K.4|^1F D.U83W.4|^ 1FD.U84E.4 |^1FD.U84K .4|^1FD.U8 4W.4|^1FD. U85E.4|^1F D.U85K.4|^ 1FD.U85W.4 |^1FM.U62E .4|^1FM.U6 2K.4|^1FM. U63E.4|^1F M.U63K.4|^ 1FM.U63W.4 |^1FM.U64E .4|^1FM.U6 4K.4|^1FM. U64W.4|^1F M.U65E.4|^ 1FM.U65K.4 |^1FM.U65W .4|^1FM.U7 1E.4|^1FM. U72E.4|^1F M.U72K.4|^ 1FM.U73E.4 |^1FM.U73K .4|^1FM.U7 3W.4|^1FM. U74E.4|^1F M.U74K.4|^ 1FM.U74W.4 |^1FM.U75E .4|^1FM.U7 5K.4|^1FM. U75W.4|^1F M.U82E.4|^ 1FM.U82K.4 |^1FM.U83E .4|^1FM.U8 3K.4|^1FM. U83W.4|^1F M.U84E.4|^ 1FM.U84K.4 |^1FM.U84W .4|^1FM.U8 5E.4|^1FM. U85K.4|^1F M.U85W.4|^ 1FT.U62E.4 |^1FT.U62K .4|^1FT.U6 3E.4|^1FT. U63K.4|^1F T.U63W.4|^ 1FT.U64E.4 |^1FT.U64K .4|^1FT.U6 4W.4|^1FT. U65E.4|^1F T.U65K.4|^ 1FT.U65W.4 |^1FT.U71E .4|^1FT.U7 2E.4|^1FT. U72K.4|^1F T.U73E.4|^ 1FT.U73K.4 |^1FT.U73W .4|^1FT.U7 4E.4|^1FT. U74K.4|^1F T.U74W.4|^ 1FT.U75E.4 |^1FT.U75K .4|^1FT.U7 5W.4|^1FT. U82E.4|^1F T.U82K.4|^ 1FT.U83E.4 |^1FT.U83K .4|^1FT.U8 3W.4|^1FT. U84E.4|^1F T.U84K.4|^ 1FT.U84W.4 |^1FT.U85E .4|^1FT.U8 5K.4|^1FT. U85W.4|^2F M.U62E.4|^ 2FM.U62K.4 |^2FM.U63E .4|^2FM.U6 3K.4|^2FM. U63W.4|^2F M.U64E.4|^ 2FM.U64K.4 |^2FM.U64W .4|^2FM.U6 5E.4|^2FM. U65K.4|^2F M.U65W.4|^ 2FM.U71E.4 |^2FM.U72E .4|^2FM.U7 2K.4|^2FM. U73E.4|^2F M.U73K.4|^ 2FM.U73W.4 |^2FM.U74E .4|^2FM.U7 4K.4|^2FM. U74W.4|^2F M.U75E.4|^ 2FM.U75K.4 |^2FM.U75W .4|^2FM.U8 2E.4|^2FM. U82K.4|^2F M.U83E.4|^ 2FM.U83K.4 |^2FM.U83W .4|^2FM.U8 4E.4|^2FM. U84K.4|^2F M.U84W.4|^ 2FM.U85E.4 |^2FM.U85K .4|^2FM.U8 5W.4|^2FT. U62E.4|^2F T.U62K.4|^ 2FT.U63E.4 |^2FT.U63K .4|^2FT.U6 3W.4|^2FT. U64E.4|^2F T.U64K.4|^ 2FT.U64W.4 |^2FT.U65E .4|^2FT.U6 5K.4|^2FT. U65W.4|^2F T.U71E.4|^ 2FT.U72E.4 |^2FT.U72K .4|^2FT.U7 3E.4|^2FT. U73K.4|^2F T.U73W.4|^ 2FT.U74E.4 |^2FT.U74K .4|^2FT.U7 4W.4|^2FT. U75E.4|^2F T.U75K.4|^ 2FT.U75W.4 |^2FT.U82E .4|^2FT.U8 2K.4|^2FT. U83E.4|^2F T.U83K.4|^ 2FT.U83W.4 |^2FT.U84E .4|^2FT.U8 4K.4|^2FT. U84W.4|^2F T.U85E.4|^ 2FT.U85K.4 |^2FT.U85W .4|^3FT.U6 2E.4|^3FT. U62K.4|^3F T.U63E.4|^ 3FT.U63K.4 |^3FT.U63W .4|^3FT.U6 4E.4|^3FT. U64K.4|^3F T.U64W.4|^ 3FT.U65E.4 |^3FT.U65K .4|^3FT.U6 5W.4|^3FT. U71E.4|^3F T.U72E.4|^ 3FT.U72K.4 |^3FT.U73E .4|^3FT.U7 3K.4|^3FT. U73W.4|^3F T.U74E.4|^ 3FT.U74K.4 |^3FT.U74W .4|^3FT.U7 5E.4|^3FT. U75K.4|^3F T.U75W.4|^ 3FT.U82E.4 |^3FT.U82K .4|^3FT.U8 3E.4|^3FT. U83K.4|^3F T.U83W.4|^ 3FT.U84E.4 |^3FT.U84K .4|^3FT.U8 4W.4|^3FT. U85E.4|^3F T.U85K.4|^ 3FT.U85W.4 "
bRetVal = !regMatch.test(sVIN);
where sVIN is a string "1FMZU62K14ZA67457".
The full sString that makes up the regMatch regular expression is "^1FB.U62E.4|^1FB.U62K.4|^
ASKER
StormyWaters,
The regular expression is for checking invalid VIN numbers, so the order and letters are very important.
Chris
The regular expression is for checking invalid VIN numbers, so the order and letters are very important.
Chris
Put the VIN numbers in an array then loop through the array.
ASKER
Hmm so I guess there's no way around it huh? Is there a limitation to the regexp .test method?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Interesting, thanks StormyWaters, I'll check that out. That would simplify things a lot :).
Chris
Chris
What code are you using exactly to make it overflow?
Regards,
Zyloch