Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex Syntax changes between POSIX and PCRE

We are currently in the process of upgrading our Varnish Cache servers. As part of the process, we upgraded only one of them to see how it behaves compared to the older versions.

Some of the major changes made in this new version is changing the regex engine from POSIX to PCRE. That means that some of our purges (regex purges) have stopped working on the newer server.

I was wondering if anyone can list/point me to a list of actual syntax differences between POSIX and PCRE. Or maybe a function that converts a POSIX regex to PCRE regex.

This is so that I can convert only the purges going to the newer server - without affecting the current regex syntax that is implemented in the system for the other servers.

like image 894
Ken Avatar asked Jan 19 '11 09:01

Ken


People also ask

What is Posix in regex?

POSIX bracket expressions are a special kind of character classes. POSIX bracket expressions match one character out of a set of characters, just like regular character classes. They use the same syntax with square brackets.

What is PCRE matching?

PCRE tries to match Perl syntax and semantics as closely as it can. PCRE also supports some alternative regular expression syntax (which does not conflict with the Perl syntax) in order to provide some compatibility with regular expressions in Python, .

What is PCRE used for?

Perl Compatible Regular Expressions (PCRE) is a library written in C, which implements a regular expression engine, inspired by the capabilities of the Perl programming language.

Is grep a PCRE?

grep understands three different versions of regular expression syntax: basic (BRE), extended (ERE), and Perl-compatible (PCRE). In GNU grep , there is no difference in available functionality between the basic and extended syntaxes.


1 Answers

See Regular Expression Engine Comparison Chart maintained by Roger Qui which a copy of the information available in the original answer. (Credit to Uberhumus for the new link.)

[Original Answer] See Flavor Comparison at Regular-Expressions.info.

like image 149
RobertB Avatar answered Oct 31 '22 02:10

RobertB