【问题标题】:My regex for oracle sql does not work我的 oracle sql 正则表达式不起作用
【发布时间】:2014-04-11 00:58:58
【问题描述】:

我正在尝试在 oracle sql 中使用 regexp_replace 函数。这是我的表格列中的示例字符串。

CV35 0DB    AC
W2 4PL      AC
OX17 7HP    AC
DE55 4RF    AC
GU13 9PU    AC
W1D 7EG     AC
CR8 2NE     AC

我想提取开头有一个字母并跟随一个数字的那些。所以只按照我的方法

W2 4PL      AC
W1D 7EG     AC

必须保留。我要强调的是,这个字符串中存在的数字也是文本。也就是说,它们不是数字。这是我尝试过的:

select distinct aa.ny,regexp_replace(aa.ny,'^[A-Z]{1}[0-9]') from  wos_source.address aa where upper(nu)='ENGLAND';

根据这个查询,它只返回:

72046       AP  72046       AP

似乎无论存在哪个角色都需要一切......

提前致谢...

【问题讨论】:

    标签: regex oracle-sqldeveloper


    【解决方案1】:

    我认为您需要在 where 子句中使用 REGEXP_LIKE:

    select distinct aa.ny from  wos_source.address aa
    where REGEXP_LIKE (aa.ny, 'pattern')
    and upper(nu)='ENGLAND';
    

    【讨论】:

      猜你喜欢
      • 2011-01-23
      • 1970-01-01
      • 2021-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-31
      • 2013-12-20
      • 2019-06-10
      相关资源
      最近更新 更多