Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^[0-9]* *([a-zA-Z]+[0-9]*)+( *\+ *[0-9]*([a-zA-Z]{1,2}[0-9]*))*$
/
gm

Description

Matches one side of a chemical equation. So for 2HCl + 2Na → 2NaCl + H2 it would match each side individually with one newline between each 2HCl + 2Na and 2NaCl + H2

Submitted by viktorashi - 5 days ago