GithubHelp home page GithubHelp logo

Potential syntax incompatibility with other engines (ex: Javascript, GO, NET or POSIX) by flexible interpretation in curly brackets about pcre2 HOT 3 OPEN

carenas avatar carenas commented on September 18, 2024
Potential syntax incompatibility with other engines (ex: Javascript, GO, NET or POSIX) by flexible interpretation in curly brackets

from pcre2.

Comments (3)

PhilipHazel avatar PhilipHazel commented on September 18, 2024 1

I always thought Perl's treatment of {,3} as a literal was an enormous gotcha, since it accepted {,3} as a qualifier. Now it treats {,3} as {0,3} which seems more reasonable. I think we should now stick with Perl compatibility but yes, add something to the docs. Anybody who cares about compatibility between engines would probably never write {,3} anyway -- they would make it clear as either {0,3} or {,3}.

from pcre2.

carenas avatar carenas commented on September 18, 2024

I always thought Perl's treatment of {,3} as a literal was an enormous gotcha

FWIW, somewhat recent versions of perl (ex: 5.30) show an error instead:

% /usr/bin/perl -e 'shift =~ /x{,3}/' 'x'
Unescaped left brace in regex is illegal here in regex; marked by <-- HERE in m/x{ <-- HERE ,3}/ at -e line 1.

Anybody who cares about compatibility between engines would probably never write {,3} anyway

At least Python, Ruby and GNU RegEx seem to interpret that qualifier just like recent Perl, so I agree.

Still the fact that this is possible AND seems to match the behaviour in other engines is worth recognizing on its own:

$ perl -e 'print "$]: $1\n" if shift =~ /(x{0, 3})/' 'x{0, 3}'
5.020002: x{0, 3}
% perl -e 'print "$]: $1\n" if shift =~ /(x{0, 3})/' 'x{0, 3}'
5.036001: x

from pcre2.

PhilipHazel avatar PhilipHazel commented on September 18, 2024

I have added a few words to the doc, pointing out that other engines may behave differently.

from pcre2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.