Regular Expressions 101

WFFs for Propositional Logic (External Paranthesises Excluded)

Open Workspace
  • PCRE2 (PHP)
  • Match
1

Regular Expression

/
^(?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