Jump to content

StringRegExp that I don't understand


Paulie
 Share

Recommended Posts

I just "Stumbled Upon" this Regular Expression that seems to be able to tell if a number is prime.

I piped it into autoit, and it seems to work!

Unfortunately, due to my limited knowledge of StringRegExp, I find myself unable to understand exactly how it works, and i was wondering if one of the RegExp Gurus here could give me an explanation of the logic behind it.

Func _IsPrime($Integer)
    $String = ""
    For $i = 1 to Number($Integer)
        $String&="1"
    Next
    If Not StringRegExp($String,"^1?$|^(11+?)\1+$") Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc
Edited by Paulie
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...