How to check EMBG (Unique Master Citizen Number) using regex

In this post, I will share my implementation of how to check if some number looks like EMBG or Unique Master Citizen Number. For those of you who are not aware what is EMBG (Unique Master Citizen Number), please check Unique Master Citizen Number . Long story short, it's a composition of 13 digits, where first 7 digits are representing date in format ddMMyyy, and for the rest of the digits please check the wiki link. The yyy are the last 3 digits of year. The last digit from the 13-digit composition is checksum number, and should be checked outside of regex checking. The following regex should be validating EMBG (Unique Master Citizen Number) for Macedonia, but can be modified to check Unique Master Citizen Number for the rest of exYu countries (except Croatia, which seems that has changed the format according to the wiki article). The regex is validating 20th and 21th century year. Also, it's aware of leap year, and validating 2902 in ddMM input, if applicable.
Here is the regex :

^(?:(?:(?:0[1-9]|1\d|2[0-8])(?:0[1-9]|1[0-2])|(?:29|30)(?:0[13-9]|1[0-2])|31(?:0[13578]|1[02]))[09]\d{2}|2902[09](?:[02468][048]|[13579][26]))4[1-9]\d{4}$

 

And the diagram for the syntax is following:


Here are some tests using powershell:


The usage of this regex can be various, starting from beginner code input testing, to some exchange transport rule or data loss prevention rules. 

Feel free to test, and have some fun.



7 comments:

  1. I love your content and the lessons you share with your readers. Every time I read a post how to write a dissertation methodology I feel like I am able to take advantage of this post.

    ReplyDelete
  2. Superslot or Thai home language is called super slot. We are an online slots provider, there are many slots games to choose from, play a lot on mobile phones, number 1, both free credit 50, 100, 150, 200 that can support both IOS and Android systems, easy to apply, have easy access to log. -in has a system to make a top-up transaction Withdraw money via automatic system 24 hours a day,

    ReplyDelete
  3. You've made some good points there. I looked on the internet for additional information about the issue and found most people will go along with your views on this website. สล็อต ฟรีเครดิต

    ReplyDelete
  4. for more info visit this link https://www.stelladatarecovery.com/email-migration/ost-to-office-365.php

    ReplyDelete
  5. Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, weed for sale

    ReplyDelete
  6. You have outdone yourself this time. It is probably the best, most short step by step guide that I have ever seen. microaire cannulas

    ReplyDelete
  7. This is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here keep up the good work xprinter label printer

    ReplyDelete

How to check EMBG (Unique Master Citizen Number) using regex

In this post, I will share my implementation of how to check if some number looks like EMBG or Unique Master Citizen Number. For those of yo...