regular expression

From IndieWeb
(Redirected from PCRE)


A regular expression is a sequence of characters used to match, extract, and/or replace patterns in text, used in many IndieWeb implementations and libraries, such as autolinkers.

Why

XKCD comic titled Regular Expressions: an elaborate fantasy scenario where use of them saves the day. Why use a regular expression?

Regular expressions can be useful (potentially even comprehensive) for parsing microsyntaxes, e.g. ISO dates.

Why not

Why not? Using regular expressions to parse more complex syntaxes (e.g. HTML) may lead to very weird errors, and potentially a source of vulnerabilities.

How to

This section is a stub.

Like most coding, find a regular expression that works for your use-case, and copy/paste.

IndieWeb Examples

Tantek

Tantek Γ‡elik uses regexes on his personal site’s code in his cassis.js library for

Tools

Variants

There are many different implementations of regular expressions. This means a regular expression that works on one platform may not be supported on an other.

See https://en.wikipedia.org/wiki/Regular_expression#Syntax for documentation of various regular expression syntaxes and variants like PCRE, differences between Perl Compatible Regular Expressions and Perl, PHP Group documentation thereof, PCRE2 use in PHP 7.3, and POSIX.

See Also