Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 368
  • Last Modified:

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.ArrayIndexOutOfBoundsException: 20" error.  Is there a limit?  And is there a way to get around it?

Thanks,

Chris
0
chriskchan
Asked:
chriskchan
  • 5
  • 3
  • 2
1 Solution
 
ZylochCommented:
Hi chriskchan,

What code are you using exactly to make it overflow?

Regards,
Zyloch
0
 
chriskchanAuthor Commented:
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.U63W.4|^1FB.U64E.4|^1FB.U64K.4" but it goes on for a long time.  It is overflowing right at the line for declaring the regexp.

Chris
0
 
ZylochCommented:
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, ArrayIndexOufOfBoundsExceptions isn't an error usually produced in Javascript. #1, javasript errors don't have java.lang. Second of all, Javascript doesn't produce ArrayIndexOutOfBoundsExceptions 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...
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
StormyWatersCommented:
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?
0
 
chriskchanAuthor Commented:
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.U63W.4|^1FB.U64E.4|^1FB.U64K.4|^1FB.U64W.4|^1FB.U65E.4|^1FB.U65K.4|^1FB.U65W.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^2FT.U83W.4|^2FT.U84E.4|^2FT.U84K.4|^2FT.U84W.4|^2FT.U85E.4|^2FT.U85K.4|^2FT.U85W.4|^3FT.U62E.4|^3FT.U62K.4|^3FT.U63E.4|^3FT.U63K.4|^3FT.U63W.4|^3FT.U64E.4|^3FT.U64K.4|^3FT.U64W.4|^3FT.U65E.4|^3FT.U65K.4|^3FT.U65W.4|^3FT.U71E.4|^3FT.U72E.4|^3FT.U72K.4|^3FT.U73E.4|^3FT.U73K.4|^3FT.U73W.4|^3FT.U74E.4|^3FT.U74K.4|^3FT.U74W.4|^3FT.U75E.4|^3FT.U75K.4|^3FT.U75W.4|^3FT.U82E.4|^3FT.U82K.4|^3FT.U83E.4|^3FT.U83K.4|^3FT.U83W.4|^3FT.U84E.4|^3FT.U84K.4|^3FT.U84W.4|^3FT.U85E.4|^3FT.U85K.4|^3FT.U85W.4"
0
 
chriskchanAuthor Commented:
StormyWaters,

The regular expression is for checking invalid VIN numbers, so the order and letters are very important.

Chris
0
 
ZylochCommented:
Put the VIN numbers in an array then loop through the array.
0
 
chriskchanAuthor Commented:
Hmm so I guess there's no way around it huh?  Is there a limitation to the regexp .test method?
0
 
StormyWatersCommented:
Couldn't you use this:
http://www.mathnotes.com/aw_IDnumber.html

to test for valid VINs?
0
 
chriskchanAuthor Commented:
Interesting, thanks StormyWaters, I'll check that out.  That would simplify things a lot :).

Chris
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now