Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(?P<WFF>(?P<L>~*(?>[A-Z\^!]|\(\g<WFF>\)))(?(?=\$)\$\g<L>|(?:(?P<O>[\%&|])(?:\g<L>\k<O>)*\g<L>)?))$
/
gx

Description

Matches strings that are Well-formed-formulas in Propositional with the following symbols {⊤,⊥,∧,∨,¬,→,↔} This matches with formulas that are looser then defined by formal syntax (See https://en.wikipedia.org/wiki/Well-formed_formula#Propositional_calculus). Namely, it's able to match with > No External Parenthesis > Generalized Conjunction, Disjunction, & Biconditional

Submitted by Gabriel Weredyk - 5 months ago (Last modified 5 months ago)