Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9260323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:51:45+00:00 2026-06-18T12:51:45+00:00

The perl negative look ahead is not working on large strings ( length >

  • 0

The perl negative look ahead is not working on large strings ( length > 40000, in active perl and cygwin perl, version 5.14 ). I tried the same code with mingw perl 5.8.8 and it stops working for strings with length > 5000.

The code I am using is:

my $str = q(A  B);
my $pattern = '(A)(?:(?!(X)).)*(B)';  
if ( $str =~ m/$pattern/ ) {
    print "matched\n";
}

This works fine for all three versions of the perl. But when I increase the length of the string by adding spaces, the pattern stops matching.

for e.g.: my $str = q(A ...some 50000 spaces... B);

Kindly help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:51:46+00:00Added an answer on June 18, 2026 at 12:51 pm

    Perl imposes an internal limit (happens to be a signed 16-bit integer on most systems) on the size of various regex operations to limit stack growth. This answer has a very good breakdown of the limit.

    From empirical testing, when the space count gets to 32767, that’s when you fail, so it’s certainly this limit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got the following error while running my perl script with the negative lookaround
How do I parse a negative number from a string in perl? I have
Perl threads do not support sharing filehandles. All the elements of a shared data
I have problem when try to shift bit for a negative number with Perl.
Perl terms confuse me and it's not my native language, so bear with me.
Context: ActiveState Perl: This is perl 5, version 12, subversion 4 (v5.12.4) built for
In Perl, I can replicate strings with the 'x' operator: $str = x x
Is there a way to get Perl to avoid treating negative values as command-line
I've this PHP function which does not work for negative numbers: function isOdd($num) {
Perl offers this very nice feature: while ( <> ) { # do something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.