0

Is 'a^b' a valid Regular Expression in oracle sql? If yes what are the strings(give some examples) that could qualify.

select name from employees where regexp_like(name,'a^b'); 
sql_dummy
  • 715
  • 8
  • 23

1 Answers1

1

It's valid, but it will never match anything. ^ is a zero-width assertion that matches the beginning of the string or right after a newline. But it can't match a\nb ( a-newline-b) because there's nothing in the regex to match the newline itself. So a^b is syntactically valid, but it's nonsense.

Alan Moore
  • 73,866
  • 12
  • 100
  • 156
  • just incase can you give regex for ( a-newline-b) – sql_dummy Feb 28 '16 at 08:23
  • Oracle's regex flavor provides no way to do that. It seems you have to use whatever mechanism is available to insert an actual newline into the regex string. In PL/SQL, from what I can gather, that's something like `'a' || CHR (10) 'b'`. – Alan Moore Feb 28 '16 at 09:31
  • ... where `regexp_like(name,'a' || CHR(10) || 'b')` – Gary_W Feb 29 '16 at 19:31