Here's a fascinating Regular Expression for identifying prime numbers:

**/^1?$|^(11+?)\1+$/**

Instead of entering numbers in base 10 or binary (base 2), this Regular Expression uses the unary numeral system (base 1). Base 1 is probably how the earliest humans first counted. 111 = 3, 11111111 = 8, etc.

It seems the more I learn about Regular Expressions, the less I know. ðŸ¤·♂️

Here's a ten minute explainer video that demos regex101.com for testing Regular Expressions.

## No comments:

## Post a Comment

Note: Only a member of this blog may post a comment.