Regex Help

I am terrible at Regular Expressions. I was wondering if anybody could help me find a string that matched his Regex:

^([A-H]|[J-N]|[P-Y]|[0-9]){25}$

I would greatly appreciate any help...

(Moderator: Thread moved to the Regular Expression Forum and Title changed for quicker thread understanding during a search)


Answer this question

Regex Help

  • AntC999

     

    Some example strings that would match your expression are all exactly 25 characters long, containing any combination of letters (A-Z) and numbers (0-9), except for the characters I, O, and Z.

     


  • anthonyjl

    Hi Nasha,

    Thanks for you help, but when I run a regex test on the 2nd string you gave me, it doesn't work. I tried it on multiple regex testing sites...


  • ChrisWall

    Hi,

    The below code works just fine for me

    private void button2_Click(object sender, EventArgs e)

    {

    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^([A-H]|[J-N]|[P-Y]|[0-9]){25}$");

    MessageBox.Show(regex.IsMatch("ABCDEFGHJKLMNPQRSTUVWXY0123456789").ToString());

    MessageBox.Show(regex.IsMatch("ABCDEJKNPQSTUXY0123456789").ToString());

    }

    Test this using C# winform.

    In case of any queries get back.

    Regards,

    Nasha



  • Firestorm353

    Hi there,

    System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex("^([A-H]|[J-N]|[P-Y]|[0-9]){25}$");

    MessageBox.Show(regex.IsMatch("ABCDEFGHJKLMNPQRSTUVWXY0123456789").ToString());

    MessageBox.Show(regex.IsMatch("ABCDEJKNPQSTUXY0123456789").ToString());

    The first line of the code above is the set of characters which are valid for this regular expression which takes characters from AtoH,JtoN,PtoY and numbers from 0to9 and the length of the string should be 25 characters.

    The second line of the code is a valid regular expression ;)

    Hope this helps.

    Get back in case of any queries.

    Regards,

    Nasha



  • Regex Help