Regular Expressions

From David's Wiki
\( \newcommand{\P}[]{\unicode{xB6}} \newcommand{\AA}[]{\unicode{x212B}} \newcommand{\empty}[]{\emptyset} \newcommand{\O}[]{\emptyset} \newcommand{\Alpha}[]{Α} \newcommand{\Beta}[]{Β} \newcommand{\Epsilon}[]{Ε} \newcommand{\Iota}[]{Ι} \newcommand{\Kappa}[]{Κ} \newcommand{\Rho}[]{Ρ} \newcommand{\Tau}[]{Τ} \newcommand{\Zeta}[]{Ζ} \newcommand{\Mu}[]{\unicode{x039C}} \newcommand{\Chi}[]{Χ} \newcommand{\Eta}[]{\unicode{x0397}} \newcommand{\Nu}[]{\unicode{x039D}} \newcommand{\Omicron}[]{\unicode{x039F}} \DeclareMathOperator{\sgn}{sgn} \def\oiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x222F}\,}{\unicode{x222F}}{\unicode{x222F}}{\unicode{x222F}}}\,}\nolimits} \def\oiiint{\mathop{\vcenter{\mathchoice{\huge\unicode{x2230}\,}{\unicode{x2230}}{\unicode{x2230}}{\unicode{x2230}}}\,}\nolimits} \)

Regular expressions are used for matching text.
You can test regular expressions online at [1].

Syntax

Letters

[a-zA-Z]

Numbers

You should match numbers using [0-9].
\d will match unicode characters which are classified as digits.
See \d vs 0-9

Useful Regular Expressions

Mostly copied from Regex DB.

Floating Point Number

Without matching scientific notation (e.g. 1.5e-6). Reference

[-+]?[0-9]*\.?[0-9]+

With matching scientific notation (e.g. 1.5e-6). Reference
Capturing significand and exponent separately.

([-+]?[0-9]*\.?[0-9]+)(?:[eE]([-+]?[0-9]+))?

Capturing the entire string together.

([-+]?[0-9]*\.?[0-9]+(?:[eE][-+]?[0-9]+)?)