+ Post New Thread
Results 1 to 7 of 7
Coding Thread, RegEx statement to recognise UPN numbers in Coding and Web Development; Hi all, I've gotten mail encryption working in office 365 and I'm looking to automatically encrypt or block messages using ...
  1. #1
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    598
    Thank Post
    79
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23

    RegEx statement to recognise UPN numbers

    Hi all,

    I've gotten mail encryption working in office 365 and I'm looking to automatically encrypt or block messages using DLP.

    So I'm looking for regex statement to find a upn and other for any other potentially sensitive info.

    I'm thinking something like this for the upn

    A|B|C|D|E|F|G|H|J|K|L|M|N|P|Q|R|T|U|V|W|X|Y|Z..... .......

    Is there a better option to find 12 decimals following one of the characters above?

    Are there too many LEAs to put those as an option into the statement?

    I could use the local lea but I'd be missing any students out of my local lea.


    Any help / ideas very greatly appreciated.

  2. #2


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,418
    Thank Post
    243
    Thanked 2,827 Times in 2,086 Posts
    Rep Power
    815
    Quote Originally Posted by Marshall_IT View Post
    Is there a better option to find 12 decimals following one of the characters above?
    Definitely!

    Code:
    [a-zA-Z]{1}\d{12}
    or better still (since it won't match if the UPN starts with an I, O or S)...

    Code:
    [a-hA-Hj-nJ-Np-rP-Rt-zT-Z]{1}\d{12}
    Btw, RegExr is a good website for testing regular expressions.
    Last edited by Arthur; 4th July 2014 at 08:06 AM. Reason: Fixed RegEx as I had it backwards

  3. Thanks to Arthur from:

    Marshall_IT (8th July 2014)

  4. #3
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    598
    Thank Post
    79
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23
    Thank you.

  5. #4

    Join Date
    Nov 2010
    Posts
    467
    Thank Post
    61
    Thanked 72 Times in 59 Posts
    Rep Power
    34
    Quote Originally Posted by Arthur View Post

    Btw, RegExr is a good website for testing regular expressions.
    I like that site. Similar to Rubular: a Ruby regular expression editor and tester

  6. #5
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    598
    Thank Post
    79
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23
    Although that statement is completely correct it doesn't work in office 365, exchange online rules section

    i've had to alter it to be

    .\d\d\d\d\d\d\d\d\d\d\d\d

    while this will/could pull up a few false positives i shouldn't let through any genuine UPNs.

  7. #6
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    598
    Thank Post
    79
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23
    Quote Originally Posted by Arthur View Post
    Definitely!


    or better still (since it won't match if the UPN starts with an I, O or S)...

    Code:
    [a-hA-Hj-nJ-Np-rP-Rt-zT-Z]{1}\d{12}
    This did actually work i just wasn't waiting long enough for Office 365 to sync the rules. they can take up to 4 hours which makes testing regex statements a pain!

    - - - Updated - - -

    Quote Originally Posted by Arthur View Post
    Definitely!


    or better still (since it won't match if the UPN starts with an I, O or S)...

    Code:
    [a-hA-Hj-nJ-Np-rP-Rt-zT-Z]{1}\d{12}
    This did actually work i just wasn't waiting long enough for Office 365 to sync the rules. they can take up to 4 hours which makes testing regex statements a pain!

  8. #7


    Join Date
    Feb 2007
    Location
    51.403651, -0.515458
    Posts
    9,418
    Thank Post
    243
    Thanked 2,827 Times in 2,086 Posts
    Rep Power
    815
    Quote Originally Posted by Marshall_IT View Post
    This did actually work I just wasn't waiting long enough for Office 365 to sync the rules. They can take up to 4 hours which makes testing regex statements a pain!
    Thanks for the update. That's good to know!

    At least you can use the correct regex now and you shouldn't get any false matches.

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 12
    Last Post: 4th June 2014, 10:44 AM
  2. How to find port number on APC UPS?
    By ihaveaproblem in forum Hardware
    Replies: 12
    Last Post: 12th July 2012, 09:19 AM
  3. Replies: 51
    Last Post: 4th July 2012, 08:51 AM
  4. Script to find serial numbers of all computers on network
    By bandgeekmafia78 in forum Scripts
    Replies: 3
    Last Post: 23rd May 2011, 05:11 PM
  5. Software or Website to Generate A Number For Bingo
    By FN-GM in forum Educational Software
    Replies: 2
    Last Post: 19th October 2010, 11:41 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •