0

I am trying to convert below regular expression to oracle compliant regular expression syntax. It seems that the look-around is not supported in Oracle. Any idea how should I make it work.

(\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.){1,2}[a-z]{2})(?=\z|[/\s])|(\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.){1}[a-z]{3,})(?=\z|[/\s])

Below query should identify the website domain accurately.

select 1
from   dual
where  REGEXP_LIKE(
         LOWER('sme other site https://www.mywebsite.com and few'), 
         '(\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.){1,2}[a-z]{2})(?=\z|[/\s])|(\b((xn--)?[a-z0-9]+(-[a-z0-9]+)*\.){1}[a-z]{3,})(?=\z|[/\s])'
       )
MT0
  • 143,790
  • 11
  • 59
  • 117
Nayn
  • 3,594
  • 8
  • 38
  • 48
  • Just change the lookaheads to `(?:\z|[/\s])` or `(\z|[/\s])` –  Mar 27 '14 at 22:58
  • both do not work. http://sqlfiddle.com/#!4/d41d8/27192 – Nayn Mar 27 '14 at 23:20
  • Oracle does not support word-boundaries `\b` or look-ahead so you need to fix both. (Or, if you have Java enabled in the database, you can [create a Java method to parse the regular expression](https://stackoverflow.com/a/74351821/1509264) and call that from SQL.) – MT0 May 02 '23 at 13:09

0 Answers0