Alter regex to validate email domain on rfc 5322 from java to oracle sql

  1. Nicha

    Nicha Starter

    Likes Received:
    Trophy Points:
    Lisbon, Portugal
    I need to alter the *below Regex* to validate emails domains in a oracle database, according to RFC 5322, and ensuring that the criteria below are respected as well.

    Domain rules that must be respected:

    1. must start an end with a letter or digit and be between 1 and 63 characters long.
    2. may contain uppercase and lowercase Latin letters (A to Z and a to z).
    3. may contain digits 0 to 9, provided that top-level domain names are not all-numeric.
    4. may contain hyphen -, provided that it is not the first or last character, and not consecutive also.
    5. must have at least 2 or more characters ( is not valid, but is valid).

    I found on the internet the regex below, that works very well and ensure the rules posted above, except .5, but is in Javascript.
    My problem is that ORACLE does not support look-ahead/-behind.

    Code (SQL):

    So, can anyone please help me on making the necessary modifications in order to work in Oracle sql?

    My best regards
    Last edited: Mar 27, 2020