Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
ECMAScript (JavaScript)

/
^(((1*),\3)|((1*),((\5)1+))|((1*),((?!\9)1+)))$
/

Description

Calculates the greatest common divisor of two numbers. Attention: pipes in the substitution separate alternatives. If one alternative does not match, the next alternative is tried if it exists. The substitution must be repeated until it cannot substitute further.

Submitted by luis140219 on GitHub - 10 years ago