REGEXP_LIKE
CREATE TABLE test
(Identification NUMBER, name VARCHAR2 (100))
);
INSERT INTO test VALUES
(1000, "Retail financing Checklist")
);
INSERT INTO test VALUES
(1001, "contract of lease financing Checklist - iDocs")
);
INSERT INTO test VALUES
(1002, 'No - private lease financing Checklist')
);
SELECT * FROM test WHERE name LIKE '% detail' OR name LIKE '% Lease'.
The above query gives me the records whose name begins as the sale at retail or rental. I am reproducing the same using regexp_like(), but it returns no records.
SELECT *.
OF the test
WHERE the REGEXP_LIKE (name '(\|) Retail\ |) | »
|| '(\| Lease\ |) | » );
Hello
MyOAF wrote:
CREATE TABLE test
(Identification NUMBER, name VARCHAR2 (100))
);
INSERT INTO test VALUES
(1000, "Retail financing Checklist")
);
INSERT INTO test VALUES
(1001, "contract of lease financing Checklist - iDocs")
);
INSERT INTO test VALUES
(1002, 'No - private lease financing Checklist')
);
Thanks for posting the CREATE TABLE and INSERT statements; It's very useful!
SELECT * FROM test WHERE name LIKE '% detail' OR name LIKE '% Lease'.
The above query gives me the records whose name begins as the sale at retail or rental. I'm trying to reproduce the same using regexp_like()
Here's a way to do it with REGEXP_LIKE:
SELECT *.
OF the test
WHERE (name REGEXP_LIKE
, ' ^(Retail|) Rental contract)"
)
;
Here, ' ^' means the beginning of the string, and ' |' or the other which means just bfore it or what comes next, so you can read the above model as "the beginning of the string, followed immediately the"Detail"or"Rental"
but it returns no records.
SELECT *.
OF the test
WHERE the REGEXP_LIKE (name '(\|) Retail\ |) | »
|| '(\| Lease\ |) | » );
' \ | "means a character literal pipe. but chracters hose play no role in this issue. The model above is looking for is ' | Retail |' or '. Rental |', and it is looking everywherre in the chain, not just at the beginning. (This is the opposite of LIKE. AS I guess you are trying to match the entire string, and you must explicitly use a wild card like '%' to tell you want to watch just a part of the string. Regular expressions assume that you are looking for anywhere in the chain, and you must explicitly anchor your boss for the beginning of the string (using the ' ^') or end (using the "$") If you are only interested in these areas.)
Tags: Database
Similar Questions
-
Regexp_like special character set
Hello
I need to know all the lines that have special characters [ranging from chr (1) to chr (31)] in a query. I am currently using the query to see chr (9) which is the TAB character below.
Select * from
Apps.ap_invoices_all
where regexp_like (invoice_num, chr (9));
Is there an interval [a - z] or [0-9] can I use to chr (1) to chr (31)
Kind regards
Prasanna
Check if it works... (not tested on my side).
WITH datafind AS ( SELECT LISTAGG (CHR (ROWNUM), '|') WITHIN GROUP (ORDER BY 1) str FROM DUAL CONNECT BY ROWNUM <= 31) SELECT * FROM apps.ap_invoices_all, datafind WHERE REGEXP_LIKE (invoice_num, str);
See you soon,.
Manik.
-
REGEXP_LIKE starting by h7 or r7 and finishing is not with _rtrd
I'm using oracle 11.2.0.3. How can I write regexp_like who will give me names beginning with h7 or r7 and finishing is not with _rtrd?
Hello
You can do all the work with only 1 REGEXP_LIKE, but it is tedious:
WHERE REGEXP_LIKE (table_name
, '^(R| H)7' || -at the beginning
'.*' || -so one of these channels...
'([^D]' ||
'| [^ R]. D' ||
'| [^ L]. RD'.
'| [^ R]. TRD' |
'| [^_] RTRD' |
($ ')' - at the end
)
-
Oracle 10 g 2: hanging of session after "select regexp_like.
Hello
We use an Oracle database 10 g 2 (10.2.0.5.0) installed on a Windows Server 2003 (x 64).
Yesterday a simple query (select * from table where regexp_like (upper (filename), ' ^ [aA - zZ] {0,1} * $')) has been started but never came back. Any other question on the same table
runs without any problem. Trying to kill the session with "alter system kill session...". "the session has maintained the State of being killed (currently for over 24 hrs.).
Seems quite odd to me since Oracle has no need to restore anything - ist was just the select which was performed at this session. The fort of event wait this session
is "SQL * Net message from client. However rebooting the computer Client did not help either. The database seems to be in good shape - at least that does not session
nothing, don't. Rebound of the database is not possible - but certainly will solve this problem.
Any ideas or maybe a bug known?
Rgds
J.
Good question, system administrator Ask, they should have a windows administration tool (I don't know the name) which will allow them to find all threads of a process Oracle.exe.
I had a similar problem and windows administrator was able to follow this thread and kill for me.
Pradeep
-
correspondence of model using regexp_like
Hi, I'm looking to match the following string using regexp_like
example of string is 86/HCFD/204010/041/PT '
I tried to use it but it looks like I'm wrong somewhere, somebody can suggest me how to go to this topic
Select 86/HCFD/204010/041/PT ' double
where REGEXP_LIKE (86/HCFD/204010/041/PT ',' [^ [[: digit:] {1,2}] + / [[: alpha:] {4,8}] + / ']);
then...
WITH the DATA (str) AS (SELECT 86/HCFD/204010/041 / PT ' DOUBLE)
Select str
FROM THE DATA
WHERE regexp_like (str, ' ^ [[: digit:]] {2} / [[: alpha:]] {4} / [[: digit:]] {6} / [[: digit:]] {3} / [[: alpha:]] {2} $');
HTH
-
Hi I want to create a function using regexp_like.
In seeking,
SQL> WITH t1 AS (SELECT '[email protected]' email FROM DUAL
2 UNION
3 SELECT '[email protected]' email FROM DUAL
4 UNION
5 SELECT 'test3@[email protected]' email FROM DUAL)
6 SELECT email
7 FROM t1
8 WHERE REGEXP_LIKE (EMAIL,
9 '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$');
EMAIL
---------------------
[email protected]
[email protected]Now i trying to create function on that.
declare
p BOOLEAN
BEGIN
P := REGEXP_LIKE ('test3@[email protected]', '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$');
IF TRUE THEN
DBMS_OUTPUT.PUT_LINE('T');
ELSE
DBMS_OUTPUT.PUT_LINE('F');
END IF;
END;
But always i get answer 'T'.....but if u see this email is invalid so i have to get 'F' insted of 'T'
So may i know why i get 'T' always ??
Thanks
Swapnil
First of all, you can not assign regexp_like<...> to a variable.
Secondly you always compare IF (TRUE) which means its always true forever, he penetrates inside and Don 't' on the screen.
Maybe something like that is what you are looking for.
set serveroutput on DECLARE p NUMBER; BEGIN SELECT 1 INTO p FROM DUAL WHERE REGEXP_LIKE ('test3@[email protected]', '^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$'); IF (p = 1) THEN DBMS_OUTPUT.PUT_LINE ('T'); END IF; EXCEPTION WHEN NO_DATA_FOUND THEN DBMS_OUTPUT.PUT_LINE ('F'); END;
See you soon,.
Manik.
-
create table t ( part_number varchar2(255) ) / insert into t values('V1ABC') / insert intot values ('ABC-12V') / commit; select * from t where REGEXP_LIKE(part_number, '(^V*[A-Z])*+$'); PART_NUMBER ------------- V1ABC ABC-12V
Must return only V1ABC
With the help of Oracle 11 g R2.
Hello
"In Oracle regular expressions," * "(asterisk) does not mean"any character. " That means "before it can occur 0 or 1 times. The wild card for any character in Oracle regular expressions is '. '. (dot). So, if you want to have
- 'V' at the beginning of the string, followed
- any character, followed by
- number any letters, from A to Z, followed
- any character at the end of the string
Here's a way to encode:
WHERE REGEXP_LIKE (part_number
, '^V' || -'V' at the beginning of the string
'.' || -any character
'[A-Z]*' || -any number of uppercase letters a Z throguh
'. $' - any character at the end of the string
)
or, more concisely,.
WHERE REGEXP_LIKE (part_number
, '^V.[A-Z]*.$'
) -
Help me with strings of small groups to interpolate the symbols in REGEXP_LIKE
If I have this PL/SQL that works very well for me and I had to add another condition, which is a REGEXP_LIKE... and I heard that
PL/SQL has a problem with special symbols and I need to get out them by interpolating, here is the line I added and I do not know how...
or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} ")"
Thank you!
Hello
Kodiak_Seattle wrote:
If this string:
or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} ")"
in SQL is fine, but when I put it in a PL/SQL it generates errors and I was told that it is because of special characters that must be broken out...
- Error (13,16): PLS-00103: encountered the symbol "=" when expected as follows: constant exception double long Ref char table time timestamp interval date binary character national nchar symbol "" was replaced by "=" continue.
- Error (25,82): PLS-00103: encountered the symbol ")" when expecting one of the following values: ( * % & = - + ; <> is mod remains not rem <> or! = or ~ = > = <=>=> <> and/or as like2 like4 likec between | Member of multiset submultiset symbol "(" a été substitué pour")" to continue. "
Here is everything:
SQL_STMT_C_1 varchar2 (2000): = ' create table Y775. TABLE_TEST COMPRESS as
Select / * + parallel (AUTO) * / a.cust_skey, a.name_first, a.name_last, a.ADDR_DELVRY, a.ADDR_DELVRY2,.
a.ADDR_CITY_NAME, a.ADDR_STATE_NAME, a.ADDR_POSTAL_CODE, b.MKT_MAIL_PREF_IND
from Table_A a, Table_B b
where a.cust_skey = b.cust_skey
and (a.A_SURV_DT > = 20101028 and b.MAIL_IND ("y", "U"))
and (instr (upper (a.ADDR_DELVRY), 'XX') > 0 OR instr (upper (a.ADDR_DELVRY2), 'XX') > 0 OR instr (upper (a.addr_city_name), 'XX') > 0)'
or REGEXP_LIKE (ADDR_DELVRY, "[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\. [a-zA-Z] {2,4} "))';
Is this really all that? Are you sure there are no (for example) of a DECLARE statement before that?
The last line you posted above is supposed to be part of the literal string assigned to sal_stmt_c_1? If so, not the literal en at the end of the line before cela.
Remember, if you want to have a single quote inside a string literal, then you must use single quotes in a row 2. You did correctly before the last line, for example, when you said:
... and (a.A_SURV_DT > = 20101028 and b.MAIL_IND IN (""Y"", """U", "")...)
Do the same sort of thing in the last line (or use Q-rating to the string literal). See the manual of the SQL language
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/sql_elements003.htm#sthref347
-
Hello
l_text1 VARCHAR2 (2500): = ' a great phrase that has, my phrase not found; And also other text ';
l_text2 VARCHAR2 (2500): = ' a great phrase that has, my - phrase not found; And also other text ';
l_search_string VARCHAR2 (2500): = ' (^ | \s|) [[: punct :]])]] My (\s+) sentence (\s+) nice (\s+) (\s+) found([[:punct:]]|\s|$)';
REGEXP_LIKE (Upper (l_text1), l_search_string) returns true
REGEXP_LIKE (Upper (l_text2), l_search_string) returns false.
Help on the search string so that it is found in text1 and text2.
Kind regards
Ngandu
Hi, Thierry.
Here's one way:
SELECT str
FROM table_x
WHERE REGEXP_LIKE (str
, '(^| ([[: punct:] [: space:]]) MY' ||
"[[: punct:] [: space:]] + SENTENCE ' |"
"[[: punct:] [: space:]] + to ' |"
"[[: punct:] [: space:]] + BE' |"
"[[: punct:] [: space:]] + FOUND' |"
"([[: punct:][:space:]]|$)'"
, 'i'
)
;
-
REGEXP_LIKE, oh where art thou?
Hey guys, it's Xev.
I use regexp_like and I have a search string that will find nine consecutive numbers and nine digits with dashes in them.
Here is this string: "[0-9]{9}$|^[0-9]{3}-[0-9]{2}-[0-9]{4}$']"
Now, I need to add this string to tell it to find Digital Alpha also...
I've seen examples of regexp like this:
SELECT *.
OF the test
WHERE REGEXP_LIKE (testcol, "[[: alnum :]]');]]")
SELECT *.
OF the test
WHERE REGEXP_LIKE (testcol, "[[: alnum:]] {3}'");
SELECT *.
OF the test
WHERE REGEXP_LIKE (testcol, "[[: alnum:]] {5}");
These examples bring above things like 'letters' (a - z) which has no numbers in them, they do research off the coast.
My question is how can I add the [[: alnum:]] to the ' [0-9]{9}$|^[0-9]{3}-[0-9]{2}-[0-9]{4}$' and we find different combinations of numbers Alpha Digital 12,13,9,8 and 6.] ".
Thank you
You are probably after the [: alpha:] class, for example:
with sample_data as (select ' TXDL 16939441' testcol, ' alpha 4, space, digits "8 comments of any double union)
Select testcol 'WVE892102', ' alpha 3, 6 digits. "the comments of union double all the
Select "TID 445689166' testcol, 3 alpha, space, comments of the nine numbers of all the double union
Select testcol 'TX21334376', ' 2 alphabetic characters, numbers 8. "comments of the Union double all the
Select "TX 12786049' testcol, ' alpha 2, space, 8 digits." comments of the Union double all the
Select testcol 'S362420598030', ' 1 alpha, 12 figures. "the comments of union double all the
Select testcol 'G20063161647', ' 1 alpha, 11 figures. "the comments of union double all the
Select testcol 'D2208703', ' 1 alpha, digit 7. "comments of union double all the
Select testcol 'E102795', ' alpha, 6-digit 1. "the comments of union double all the
Select "K01-44-4855' testcol, ' 1 alpha, 2-digit, dash, 2 digits, hyphen, 4 digits." any double union comments
Select '5563107788760' testcol, comments double union all ' 13 digit consecutive. »
Select testcol '466767189', ' 9 figures. "comments on all double union
Select testcol '23386895', ' 8 figures. "comments on all double union
Select ' 77-777-7777 testcol, ' 3 digits, dash, 2 digits, hyphen, 4 digits. "comments of the Union double all the
Select testcol '16618667TX', ' 8 digit, alpha 2. "comments of the Union double all the
Select '14067641 TX' testcol, ' 8 digit, space, alpha 2. "comments of the Union double all the
Select '003671363 THE' testcol, ' 9 numbers, space, alpha 2. "comments of the Union double all the
' Select ' TXID 11946262 ' testcol, ' 8 digit, space, alpha 4. "comments of the Union double all the
Select '1111111111' testcol, ' shouldn't "t match - 10 consecutive double-digit)
Select testcol,
Comments,
-case when regexp_like (testcol,'^ [[: alpha:]] {4} \s [0-9] {8} $' |)
'|^[0-9]{9}$'||
' | ^ [(0-9]{3}-[0-9]{2}-[0-9]{4}$')]
then 'Y' else ' n end check_col
of sample_data;
(I left the rest as an exercise for the OP, also I took the liberty of the difference between the two sets (effectively) 8 digits and 2 letters, by doing a have a space and the other not.) It was not difficult to come up with the rest of the conditions...)
-
Regexp_like instead of to_number function
All good Dale
I'm writing a query to check if something is a number. So far, I've had this
Select 1
of the double
where regexp_like (1.1, ' ^ [--------+---------]?) [ 0-9] * \. ? [0-9]+$');
But it won't work for floating numbers and I don't know why.
[\+\-]? -This should mean corresponds to + or - o or 1 times
[0-9] *-match number 0 or more times
\.? -Time match 0 or 1 point
[0-9] + -match 1 or more times number
Best regards
Igor
'E' is also part of the numbers, if you use scientific notation...
SQL > select 1.3E18 from double;
1.3E18
----------
1.3000E + 18So, is it not better to use "TO_NUMBER" which takes into account all the numbers rather than trying to build your own?
Why reinvent the wheel?
-
REGEXP_LIKE number vs varchar2
Dear friends,
I need to validate a base data type number against a list of values stored in a column varchar2.
the list is stored in a column varchar2 and is like the following (note the zero to 0 after 1.6):
1.00
1.60
0.66
validation should occur for several numbers, each time against the same set of samples varchar2:
need to validate against the list 1.25 (1.00, 1.60, 0.66)
need to validate against the same list 1.50 (1.00, 1.60, 0.66)
need to validate 1.66 always against the same list (1.00, 1.60, 0.66)
because I do not want to run the query every time I need to validate number, I tried to build a string in the list do something like the following:
If regexp_like (my_number, ' ^ $ 1.00 | ^ $ 1.60 | ^ $ 0.66 ' then...)
where the channel model ('^ $ 1.00 | ^ $1.6 | ^ $ 0.66 ') is generated at the beginning of the validation program once.
questions received so far:
' ^ $ 1.00 | ^ $ 1.66. ^ $ 0.66 ' does not recover 1
' ^ 1$ | ^ $ 1.66. ^. $ 66 ' gets 1 but also 466, 106 and so on.
Have you any idea what should be the pattern for this string?
Alternatively, could you suggest a different approach?
Thank you
Concerning
Giuseppe
Hello
You cannot use a select * on a nested table - if you want to do this, you need a sql - type (create type...) not a type in a plsql block definition.
Have you tried the listagg - instr variant I described?
Greetings
Chris
-
REGEXP_LIKE for more of a range of numbers.
Hi all.
It is a pleasure to receive your help.
I use Oracle Database 10 g Enterprise Edition Release 10.2.0
I want to leave a string of pairs of numbers (where each pair represents a range) to know if my setting number is between pairs.
Something like the following.
SQL:
declare i pls_integer := 0; s varchar2(100) := '^([74010000-74019999]|[85990000-85990999])'; test1 varchar2(8) := '64010000'; test2 varchar2(8) := '74010000'; begin begin select 1 into i from dual where regexp_like(test1, s); dbms_output.put_line(i); exception when no_data_found then dbms_output.put_line(0); end; begin select 1 into i from dual where regexp_like(test2, s); dbms_output.put_line(i); exception when no_data_found then dbms_output.put_line(0); end; end;
With the expected result below.
Output (It didn't happen):
0 1
Actual output:
1 1
Suggestions?
I'm looking for the literal correct.
I thank in advance
Filippe
No prob
drop table test
CREATE TABLE test
(NUMBER n
);
INSERT INTO test (n) VALUES (64010000);
INSERT INTO test (n) VALUES (74010000);
with input_data as)
Select regexp_substr (t.val, "[^;]") +', 1, level * 2-1) to_search, regexp_substr (t.val, "[^;]") +', 1, level * 2) end_num
(Select '74010000; 74019999; 84010000; 84019999; 94010000; 94019999' VAL double) t
connect regexp_substr (t.val, "[^;]") +', 1, level * 2) IS NOT NULL
)
Select
*
of input_data, test
where
n between to_search and end_num
TO_SEARCH END_NUM N
74010000 74019999 74010000
Just to get the whole picture
with input_data as)
Select regexp_substr (t.val, "[^;]") +', 1, level * 2-1) to_search, regexp_substr (t.val, "[^;]") +', 1, level * 2) end_num
(Select '74010000; 74019999; 84010000; 84019999; 94010000; 94019999' VAL double) t
connect regexp_substr (t.val, "[^;]") +', 1, level * 2) IS NOT NULL
)
Select
*
Of
input_data
full outer join
test
on
n between to_search and end_num
TO_SEARCH END_NUM N
74010000 74019999 74010000
84010000 84019999-
94010000 94019999-
-6401000
chris227: the entire image added
be complete it shoul be "n between to_number (start_num) and to_number (end_num)" accuracy
-
Hello
I am confused with the following example of REGEXP_LIKE
The statement SELECT abvoe gives 2records. I don't expect that one folder must be returned by the query abovecreate table test_like (nm1 varchar2(11)) insert into test_like values ('AUS' ) ; insert into test_like values ('ATS' ) ; select * from test_like where regexp_like(nm1,'*AT*');
Please give me a hint on this
Thank youYou don't need *.
select * from test_like where regexp_like(nm1,'AT');
or
SQL> select * from test_like where regexp_like(nm1,'.*AT.*'); NM1 ----------- ATS
Published by: JAC on May 22, 2013 16:19
Your model (* AT *) means, whatever it is - A then - then T zero or more times.
-
Regexp_like with check constraint
Hi all
My requirement is user does not enter data such as (½, ¼,...).
I created the table with the constraint validation with the following syntax:
CREATE TABLE mytest (c1 VARCHAR2 (20),)
CHECK (REGEXP_LIKE(c1,'^[[:alnum:]+[:digit:]+[!@#]]+$')));)
The means above, except alphanumeric, should enable figures and characters from the keyboard. But it does not have any character.
Please help me, any error in the syntax above.
Thank you
ManoAlnum already includes numbers well, you don't need to Pack! @# in [] within []:
SQL> CREATE TABLE mytest (c1 VARCHAR2(20), 2 CHECK (REGEXP_LIKE(c1,'^[[:alnum:]!@#]+$'))); Table created. SQL> insert 2 into mytest 3 values('@xyz1abc') 4 / 1 row created. SQL> insert 2 into mytest 3 values('@xyz1abc*') 4 / insert * ERROR at line 1: ORA-02290: check constraint (SCOTT.SYS_C0019122) violated SQL>
SY.
Maybe you are looking for
-
Restart Firefox and restarting the computer didn't help.
-
Problems of excessive noise and fan performance.
(I found a few similar posts, none seem to have any kind of resolution. I already submitted details to the comments for OS - X and MacBook Pro, because I know that Apple doesn't really care these forums.) I'm computer LITERATE in a company with more
-
Blank disk backup stalling my restore
My HP Vista Home Premium computer crashed, so I used 17 DVD to back up my files. Now I use Recovery Manager to restore my files using the backup disks, but disk #4 is empty. The first three DVDs very well restored. The Recovery Manager will not ig
-
Hi, here: http://docs.blackberry.com/de-de/developers/deliverables/20764/Resources_769692_11.jsp I was redirecting to the Page Webworks. But where can I download the Addin in Studio Visual. All other google links are not real. Greetings, Thorsten
-
Is it possible to pan and zoom in the site?
I made a drawing of a city that is large enough. The site can be seen on www.vpbengemeente.nl and scroll vertically in the image. Although pc users are not able to scroll from left to right and vv. My client asked me to change the image in a way that