oracle regexp_substring仅返回部分模式

时间:2019-11-11 16:03:19

标签: oracle

Regexp_substr仅返回搜索模式的一部分。

  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

它返回没有数字的“数字№”。但是,搜索效果很好:示例代码中没有“№3”,则不会返回

1 个答案:

答案 0 :(得分:1)

我认为,对于Oracle,这个时髦的字符实际上可以算作一个以上的字符。将.{0,4}扩展到.{0,5}似乎可行:

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