473,549 Members | 2,408 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Maximum length for a match

I know this may sound silly but given something like

if ($_ =~m/(one)|(two)|(th ree)/)

Is there a maximum length on the size of the item between "/" and" /"
?
Just curious as regards showing bad programming techniques.

TIA Paul
Nov 28 '06 #1
2 3382
In article <70************ *************** *****@4ax.com>, Paul Johnston
<pa***********@ manchester.ac.u kwrote:
I know this may sound silly but given something like

if ($_ =~m/(one)|(two)|(th ree)/)

Is there a maximum length on the size of the item between "/" and" /"
?
Just curious as regards showing bad programming techniques.
There is no inherent limit. You are limited by your available memory
for Perl scalars. You can test this easily:

#!/usr/local/bin/perl

use strict;
use warnings;

my $re;
for my $x ( 'aaaa' .. 'zzzz' ) {
$re .= "($x)|";
}
my $s = 'XXXXX';
$re .= "($s)";
print "Length of RE = ", length($re), "\n";
if( $s =~ m/$re/ ) {
print "Match: $&\n";
}

__OUTPUT__

Length of RE = 3198839
Match: XXXXX
FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.
Nov 28 '06 #2
On Tue, 28 Nov 2006 10:21:50 -0800, Jim Gibson
<jg*****@mail.a rc.nasa.govwrot e:
>In article <70************ *************** *****@4ax.com>, Paul Johnston
<pa*********** @manchester.ac. ukwrote:
>I know this may sound silly but given something like

if ($_ =~m/(one)|(two)|(th ree)/)

Is there a maximum length on the size of the item between "/" and" /"
?
Just curious as regards showing bad programming techniques.

There is no inherent limit. You are limited by your available memory
for Perl scalars. You can test this easily:

#!/usr/local/bin/perl

use strict;
use warnings;

my $re;
for my $x ( 'aaaa' .. 'zzzz' ) {
$re .= "($x)|";
}
my $s = 'XXXXX';
$re .= "($s)";
print "Length of RE = ", length($re), "\n";
if( $s =~ m/$re/ ) {
print "Match: $&\n";
}

__OUTPUT__

Length of RE = 3198839
Match: XXXXX
FYI: this newsgroup is defunct. Try comp.lang.perl. misc in the future.
Many Thanks
Nov 29 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
2086
by: KemperR | last post by:
Dear All, may be some of you can help me with an XSLT example how to solve the following challange. For the XML below I want to find out the maximum hierarchy level for a specific element in my XSLT. The result for the example (searching for <A/>) should be 4 as the element A is nested 4 times maximum. I guess I have to use somehow the...
8
4721
by: Hal Vaughan | last post by:
Is there a maximum length for Javascript program lines? What about strings? Is there a limit on string length? I found some references that said the maximum string length was 256 characters, but I have a program that created a string of over 25,000 characters (the browser was Konqueror). Are there limits on these lengths? If I require...
3
5002
by: Dave Crypto | last post by:
Hi There, SUMMARY: I need to know what the actual maximum date limit possible on a row of a MYSQL database. MORE DETAILS: For example, does a MYSQL database only allow 4032 bytes of data to be
2
28544
by: Kums | last post by:
What is the maximum permissible size of a database? Is there any limitation. What is the maximum # of tablespace's allowed in a database? Thanks for your response.
14
11369
by: olekristianvillabo | last post by:
I have a regular expression that is approximately 100k bytes. (It is basically a list of all known norwegian postal numbers and the corresponding place with | in between. I know this is not the intended use for regular expressions, but it should nonetheless work. the pattern is ur'(N-|NO-)?(5259 HJELLESTAD|4026 STAVANGER|4027...
3
21998
by: hug | last post by:
The valid character set for the ID= attribute of html tags is listed here (http://www.htmlhelp.com/reference/html40/attrs.html) but I am having difficulty finding the maximum allowable length of the id string. ? tia. -- http://www.ren-prod-inc.com/hug_soft/store.php?action=contact
7
64794
by: Martin Pöpping | last post by:
Hello, does a String in C# have a maximum length? I tried to write a ToString Method of my class containing a hashtable. At the beginning of the method i defined a String "ret". In every iteration of my hashtable I add the content with ret += "...". After some time my programm crashes.
24
4813
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross multiple lines. It would appear though that every distinct set of data starts with a 'code' that is always the 25 characters long. The text is variable...
1
2593
by: hn.ft.pris | last post by:
"Forward maximum match" mean that there is a dictionary contains thousands of items which are single words. For example, "kid", "nice", "best"... And here get a string "kidnicebs", the forward maximum match algorithm need to find the longest string that matches the string in dictionary. Because the longest string in the dictionary has a...
0
7467
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7982
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7500
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7827
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6066
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5385
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3514
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3494
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
783
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.