the union operation
Sometimes a pattern allows more than one possibility, like a form that accepts either 'Mr' or 'Ms'. The union operation in a regular expression is the way to say 'either this pattern or that one'. If you can describe two families of strings separately, union lets you accept anything from either family.
If R and S are regular expressions, the union R+S (often written R|S in programming) denotes the set union of their languages: a string matches R+S exactly when it matches R or it matches S (or both). In set notation, L(R+S) = L(R) ∪ L(S), where ∪ is set union. For example, over {a, b}, the expression a+b denotes { a, b }, and (ab)+(ba) denotes { ab, ba }. Union is the regular-expression operator that corresponds directly to the everyday word 'or'.
Union is commutative and associative (the order and grouping of alternatives do not matter) and it is idempotent: R+R denotes the same language as R, because a set union with itself adds nothing. The empty set ∅ is its identity element: R+∅ denotes the same language as R, since unioning in 'no strings' changes nothing. These facts are part of the algebra of regular expressions and let you simplify big expressions.
The expression (a+b+c)* denotes all strings over the three-letter alphabet {a, b, c}: at each position you may pick a or b or c, zero or more times. Without union you would have to enumerate every combination by hand.
Union packs 'any of these choices' into one symbol.
Union corresponds to set union, so it is idempotent: R+R = R as languages. This differs from arithmetic '+', where x+x = 2x. The symbol is borrowed but the meaning is set-theoretic 'or'.