Regular Expression to check for Prime Number

By Santhosh N

This explains how to check if the given number is Prime number or not using Regular expressions

Regular Expressions could be used to check if the given number is Prime or not. This is the regex to check for Prime numbers

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

This works in perl and ruby which was tested atleast and you could use in other languages as well.

Related FAQs

This is how trimming of a string can be done in javascript is simpler manner.
Regular Expression to check for Prime Number  (1180 Views)