0

I have the following expression that is working to catch multiple emails or one single reserved word (eg. STACK, STACK_OVERFLOW).

^(([a-zA-Z\-0-9\.\_]+@gmail.com)[;]*)+$|^([A-Za-z]+\_?[A-Za-z]+)$

But when I try to use it in a condition like for example:

SELECT 1
  FROM DUAL
 WHERE REGEXP_LIKE ('stack_overfow@gmail.com', '^(([a-zA-Z\-0-9\.\_]+@gmail.com)[;]*)+$|^([A-Za-z]+\_?[A-Za-z]+)$');

It doesn't give me null, it gives me an error instead

ORA-12728: invalid range in regular expression
12728. 00000 -  "invalid range in regular expression"
*Cause:    An invalid range was found in the regular expression.
*Action:   Ensure a valid range is being used.

What could be the cause?

Barbaros Özhan
  • 47,993
  • 9
  • 26
  • 51
SnakeSheet
  • 149
  • 2
  • 10
  • 1
    Put `-` at the character class end or start and remove all backslashes in your regex. – Wiktor Stribiżew Oct 28 '19 at 09:48
  • The purpose of your regex is not very clear. It would help if you could provide example of values that should match and values that should not match. – GMB Oct 28 '19 at 09:52
  • `[a-zA-Z0-9._-]+`. Also, if you are accepting `gmail` emails then please allow the `+` character in the e-mail; so the regular expression `(([a-zA-Z0-9._-]+(\++[a-zA-Z0-9._-]+)?@g(oogle)?mail.com)[;]*)+$` as `stack_overflow++yourdomainname.com@googlemail.com` is an acceptable e-mail address that google will route to `stack_overflow@gmail.com` and allows users to track who they've given an e-mail address to; its annoying when sites don't accept valid e-mails when it doesn't match some developer's arbitrary expectations of how an e-mail should look. **Even better support RFC5322/6854.** – MT0 Oct 28 '19 at 10:04

0 Answers0