Parse your email address in Oracle to count the number of addresses with 3 or less characters before the @ sign

I need to count the number of email addresses in db that have 3 or less characters before the @ sign, e.g. ab@test.com.

The parseame function is missing in Oracle, and I'm not sure how to write regexp for this. Any help would be greatly appreciated!

+3
source share
4 answers

Regex is superfluous for this. All you need is

instr(t.email, '@') < 5 AND instr(t.email, '@') > 0

Edited to correct comments.

+7
source

You want a regex:

^[^@]{0,3}@

In English, this is:

  • Start line
  • 0 , .
  • .
+2

WHERE COUNT REGEXP_COUNT:

SELECT REGEXP_COUNT(t.email, '^[^@]{0,3}@', 1, 'i') RESULT
  FROM TABLE t;

COUNT:

SELECT COUNT(*)
  FROM TABLE t
 WHERE REGEXP_LIKE(t.email, '^[^@]{0,3}@')

:

+2

instr (t.email, '@') < 5

, t.email "@"! , t.email "@"

+1

Source: https://habr.com/ru/post/1753383/


All Articles