Alter Regex to validate email Domain on RFC 5322 from Java to Oracle sql

二次信任 提交于 2021-01-29 12:24:44

问题


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 (abc@t.com is not valid, but abc@tt.com is valid).

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

@(?:(?=[A-Z0-9-]{1,63}\.)[A-Z0-9]+(?:-[A-Z0-9]+)*\.){1,8}[A-Z]{2,63}$

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

来源:https://stackoverflow.com/questions/60870491/alter-regex-to-validate-email-domain-on-rfc-5322-from-java-to-oracle-sql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!