Noel
Noel

Reputation: 10525

Usage of REGEXP_SIMILAR in Teradata

I'm working on Teradata and trying to use REGEXP_SIMILAR function.

 *** Teradata Database Release is 14.10.03.10                   
 *** Teradata Database Version is 14.10.03.06  

Here's my sample data.

create table test_table(
    test_col varchar(20)
);

insert into test_table values('lorem');
insert into test_table values('984kd');
insert into test_table values('ier7j');
insert into test_table values('34535');
insert into test_table values('lore9');
insert into test_table values(' 09sd');

I want to see the records which start with a number.

select test_col, regexp_similar(test_col, '^\d+','i')
from test_table;

test_col              regexp_similar(test_col,'^\d+','i')
--------------------  -----------------------------------
lore9                                                   0
lorem                                                   0
 09sd                                                   0
ier7j                                                   0
984kd                                                   0
34535                                                   1

But, the above query shows a match only for '34535' row and not for '984kd'. Seems like ^ character(also $) don't have the desired effect.

Isn't REGEXP_SIMILAR similar to REGEXP_LIKE of Oracle?

Can someone explain why is this happening and how to solve this.

Upvotes: 0

Views: 15279

Answers (1)

vks
vks

Reputation: 67968

^\d+.*

Try this.This will give the result.

Upvotes: 1

Related Questions