Regular Expressions 101

Community Patterns

WFFs for Propositional Logic (External Paranthesises Excluded)

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 - a month ago (Last modified 25 days ago)