Regexp_like [message #683599] |
Fri, 05 February 2021 14:32 |
rajivn786
Messages: 161 Registered: January 2010
|
Senior Member |
|
|
Hi,
I am having some difficulty in writing regexp. I need to find those that match "you" in a string, but it's picking "your" as well.
select 1 from dual
where regexp_like('Your Mother',
'(^|[^A-Z]+)' || 'You' || '([^A-Z]+|$)');
The code should return 1 if it has "you" and not "your" but it's returning 1. I am new to regexp. Can anyone advise?
|
|
|
|
|
Re: Regexp_like [message #683602 is a reply to message #683600] |
Fri, 05 February 2021 14:46 |
rajivn786
Messages: 161 Registered: January 2010
|
Senior Member |
|
|
Unfortunately I added only just 1 simple one . My mistake. We are not sure of the position of "you".
It can be anywhere like below
Some of the data I had were :
Father's Parents
Father Father's Parents You
Father Father's Parents You Siblings
Father Father's Parents Mother's Parents Siblings
Children Father Mother's You Parents Siblings
Children Mother's Parents Siblings You
Children Father Father's Parents You Mother's Parents Siblings
|
|
|
|
Re: Regexp_like [message #683604 is a reply to message #683603] |
Fri, 05 February 2021 15:21 |
rajivn786
Messages: 161 Registered: January 2010
|
Senior Member |
|
|
I think this works only if first 3 letters are "you"
COnsider this table and output .
Drop table a;
Create table a (cd varchar2(100));
Insert into a values ('Father''s Parents');
Insert into a values ('Father Father''s Parents You');
Insert into a values ('Father Father''s Parents You Siblings');
Insert into a values ('Your Father Father''s Parents Mother''s Parents Siblings');
Insert into a values ('Children Father Mother''s You Parents Siblings');
Insert into a values ('Children Mother''s Parents Siblings You');
Insert into a values ('Children Father Father''s Parents Your Mother''s Parents Siblings');
O/p should be :
Father Father''s Parents You
Father Father''s Parents You Siblings
Children Father Mother''s You Parents Siblings
Children Mother''s Parents Siblings You
|
|
|
|
|
Re: Regexp_like [message #683607 is a reply to message #683606] |
Sat, 06 February 2021 01:43 |
|
Michel Cadot
Messages: 68694 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
Not exactly:
SQL> select 1 from dual where regexp_like('to you, to me','^(.*\s+)?you(\s+.*)?$', 'i');
no rows selected
Complete solution in in previous topic.
|
|
|