Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RegEx Max Limit

Status
Not open for further replies.

behbeh

Programmer
Mar 10, 2001
48
0
0
US
Hello!
Does anyone know if there is a maximum number or words/strings you can use in regex alternations?
(Ex: OH | Ohio | PA | Pennsylvania | RI | Rhode Island |...)
I know regex's are fast but if there is a limit or if hundreds of words in the alternation would slow it down to a crawl, I would greatly appreciate knowing this prior to building my expressions.
Thanks!
 
I imagine that you can create a fairly lengthy expression, but it will sap the RAM if it's too long (are we talking > 1M here?)

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
I have one regex I would need to have a little over 1,800 words listed in the alternation part. This would be sucked out of a database table as a regex string and then used in the front-end of the app.
 
That doesn't sound too bad - let us know how it goes...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
IMO regex might not be the right tool for the job, particularly for a javascript solution.

What's the length of the string? 10k characters? Remember if it is javascript it is the users' cpu / memory being hosed :)

Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
clarkin - I was thinking that this was server-side...

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
When all is said and done, the length of the string would be around 3,500 characters. I guess I'm not so concerned at this point about the memory being hosed (this would have to be tested), I just want to make sure there isn't a MAX limit to the length of a regex. If there is no limit to the length of the altrernation, then I will know that it's being hosed because of the cpu/memory.
[ponder]
 
whoops...I meant 35,000 characters!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top