user1585476
user1585476

Reputation: 33

oracle regexp_substring return only part of pattern

Regexp_substr return only part of searching pattern.

  SELECT
  REGEXP_SUBSTR('im searching value beginning from keyword with word "number" and digits after it like number № 3 in the string',
                '(number.{0,4}\d{1,2})')

                "REGEXP_SUBSTR"
  FROM DUAL

Its returning "number №", without digits. However, search works fine: without "№ 3" in sample code it return none

Upvotes: 1

Views: 120

Answers (1)

GMB
GMB

Reputation: 222702

I think that this funky character may actually count for more than one character for Oracle. Extending .{0,4} to .{0,5} seems to work:

SELECT
  REGEXP_SUBSTR(
      'im searching value beginning from keyword with word "number" and digits after it like number № 3 in the string',
      '(number.{0,5}\d{1,2})'
  ) "REGEXP_SUBSTR"
  FROM DUAL

Demo on DB Fiddle

Upvotes: 1

Related Questions