Oracle regular expressions REGEXP_SUBSTR
Hi,
I'm relatively new here and this is might be a kind of silly.
Start using reg expressiona and do not know how to get the second pattern from the end (7 in this case)?
select REGEXP_SUBSTR('1/2/3/4/5/6/7/8' ,'[^/]+$',1, 1),
REGEXP_SUBSTR('1/2/3/4/5/6/7/8' ,'[^/]+$',1, 2),
REGEXP_SUBSTR('1/2/3/4/5/6/7/8' ,'[^/]+$')
from dual;
Please help.
Edited by: lsy_nn on Jul 21, 2010 1:51 PM
RegExp_Replace is useful ;-)
Let us read these threads.
I have created part4 :8}
Introduction to regular expressions part1 to part4
Introduction to regular expressions ...
Introduction to regular expressions ... continued.
Introduction to regular expressions ... last part.
Introduction to regular expressions part4
col extStr for a10
select
RegExp_Replace('1/2/3/4/5/6/7/8',
'^.*([^/]+)/.*$',
'\1') as extStr
from dual;
EXTSTR
7
Similar Messages
-
Oracle Regular Expressions in Java?
JDEV 10.1.3
ADF BC
ADF Faces
Is there a Java library for dealing with Oracle regular expressions? I would like to be able to test a String against an Oracle regular expression for pattern match.
Thank you,Hi,
Java supports RegularEpressions: http://www.exampledepot.com/egs/java.util.regex/pkg.html
Frank -
Oracle Regular expression issue
Hi All,
I have regular expression problem.
create table url ( Url varchar2(1024));
insert into URL values ('http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm')
insert into URL values ('.*amazon.com.*');
insert into URL values ('Abc.com');
insert into URL values ('xyz.Abc.com');
insert into URL values ('^http://bhido.jambo.com/ababs/kd.htm ');
commit
SELECT url,REGEXP_SUBSTR(url,'http://([[:alnum:]]+\.?){3,4}/?') "REGEXP_SUBSTR"
FROM url
But it returns following result
URL REGEXP_SUBSTR
http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm http://abc.jambo.com/
.**abc.amazon.com.** NULL
Abc.com NULL
xyz.Abc.com NULL
.**amazon.com.** NULL
^http://bhido.jambo.com/ababs/kd.htm http://bhido.jambo.com/
*What changes would be required in RegEx to get following output*
*URL REGEXP_SUBSTR*
http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm abc.jambo.com
.**abc.amazon.com.** abc.amazon.com
Abc.com Abc.com
xyz.Abc.com xyz.Abc.com
.**amazon.com.** amazon.com
^http://bhido.jambo.com/ababs/kd.htm bhido.jambo.comThanks in advance
-Kuldeep
Edited by: Kuldeep2 on Apr 28, 2009 3:56 AM
Edited by: Kuldeep2 on Apr 29, 2009 3:28 AMSQL> select url, regexp_substr(url,'[[:alnum:]|\.]*com')new_url from url
2 /
URL NEW_URL
http://abc.jambo.com/ababs/sffef/dsf/sdfdsf/jk.htm abc.jambo.com
.*amazon.com.* amazon.com
Abc.com Abc.com
xyz.Abc.com xyz.Abc.com
^http://bhido.jambo.com/ababs/kd.htm bhido.jambo.com -
Oracle regular expression help
I have worked with regular expressions a little bit in unix scripting.
I need to diff two schemas to look for missing objects.
Problem: I changed the naming conventions.
My objects used to end with '_T' and now end with '_MV'
I cant use regular instr because I can have
HELLO_TYPES_T or I could have HELLO_T
I want to trim off the last T and MV and then do a minus to see if I am missing objects.
I I think I need to use regexp_instr with an end of line regular expression, but I can't get the syntax correct. Can someone give me a hand?Well, how about this:
SQL> with schema1
2 as ( select 'HELLO_TYPES_T' obj from dual union all
3 select 'HELLO_T' from dual union all
4 select 'TYPES_T' obj from dual union all
5 select 'HELLO_TYPES_MV' obj from dual union all
6 select 'HELLO_MV' from dual union all
7 select 'TYPES_MV' obj from dual union all
8 select 'OBJECTS_T' obj from dual )
9 , schema2
10 as ( select 'HELLO_TYPES_T' obj from dual union all
11 select 'HELLO_T' from dual union all
12 select 'TYPES_T' obj from dual union all
13 select 'HELLO_TYPES_MV' obj from dual union all
14 select 'HELLO_MV' from dual union all
15 select 'TYPES_MV' obj from dual)
---actual query
16 select regexp_replace(obj, '^*(_T|_MV)$', '') regexp
17 from schema1
18 minus
19 select regexp_replace(obj, '^*(_T|_MV)$', '') regexp
20 from schema2;
REGEXP
OBJECTS
1 row selected.And vice versa (schema2 minus schema1) -
Need PL/SQL - Oracle Regular Expressions help
Hi all,
I have to create script some schema in oracle database to update our SVN. And after create DDL scrip need to do some modification (Ex: add columns). Example as follows,
After create table DDL original scripts as follows,
--table format 1
CREATE TABLE "USER"."TABLE1"
"COLUMN1" NUMBER,
"COLUMN2" NUMBER,
"COLUMN3" NUMBER,
"COLUMN4" VARCHAR2(20 BYTE),
PRIMARY KEY ("COLUMN1") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "T1" ENABLE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 35651584 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE1_COLUMN2" ON "USER"."TABLE1"
"COLUMN2"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 196608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE1_COLUMN3" ON "SPIDERP4"."TABLE1"
"COLUMN3"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 458752 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
--table format 2
CREATE TABLE "USER"."TABLE2"
"COLUMN1" NUMBER,
"COLUMN2" NUMBER,
"COLUMN3" NUMBER,
"COLUMN4" VARCHAR2(20 BYTE)
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 35651584 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE2_COLUMN1" ON "USER"."TABLE2"
"COLUMN1"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 196608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE2_COLUMN2" ON "SPIDERP4"."TABLE2"
"COLUMN2"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 458752 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
I need to include following amendment to above table scripts (expecting results),
--1
CREATE TABLE "USER"."TABLE1"
"COLUMN1" NUMBER,
"COLUMN2" NUMBER,
"COLUMN3" NUMBER,
"COLUMN4" VARCHAR2(20 BYTE),
_*"COLUMN5" NUMBER(3,0) DEFAULT 0,*_
PRIMARY KEY ("COLUMN1") USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT) TABLESPACE "T1" ENABLE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 35651584 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE1_COLUMN2" ON "USER"."TABLE1"
"COLUMN2"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 196608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE1_COLUMN3" ON "SPIDERP4"."TABLE1"
"COLUMN3"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 458752 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
--2
CREATE TABLE "USER"."TABLE2"
"COLUMN1" NUMBER,
"COLUMN2" NUMBER,
"COLUMN3" NUMBER,
"COLUMN4" VARCHAR2(20 BYTE),
_*"COLUMN5" NUMBER(3,0) DEFAULT 0*_
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING STORAGE
INITIAL 35651584 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE2_COLUMN1" ON "USER"."TABLE2"
"COLUMN1"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 196608 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
CREATE INDEX "USER"."TABLE2_COLUMN2" ON "SPIDERP4"."TABLE2"
"COLUMN2"
PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS STORAGE
INITIAL 458752 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT
TABLESPACE "T1" ;
/Note:
I need solution apart from these conditions,
1)Table cannot be modify before create DDL (DDL creating using this method “dbms_metadata.get_ddl” ).
2)This is automated processes manual modification cannot be allow.
3)We cannot hard-coded any Dynamic Values because above create DDL table just for explain my question.(**note : “PCTFREE” ,” PRIMARY KEY”, “),”.... above values can be hard-coded**)
Thanks
Tharindu Dhaneenja
Edited by: Dhaneenja on Mar 14, 2011 11:16 PM
Edited by: Dhaneenja on Mar 14, 2011 11:17 PM
Edited by: BluShadow on 15-Mar-2011 09:08
Added {noformat}{noformat} tagsnot very safe code to do what you are looking for...
=================test data========================
SET ECHO ON FEED OFF LIN 2000 PAGES 9999 LONG 1000000 LONGC 1000 TRIMS ON;
EXEC DBMS_METADATA.SET_TRANSFORM_PARAM( DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',TRUE);
DROP USER u CASCADE;
GRANT DBA TO u IDENTIFIED BY u;
CREATE TABLE u.t1
c1 NUMBER,
c2 NUMBER,
c3 NUMBER,
c4 NUMBER,
PRIMARY KEY (c1)
CREATE TABLE u.t2
c1 NUMBER,
c2 NUMBER,
c3 NUMBER,
c4 NUMBER
CREATE TABLE u.t3
c1 NUMBER NOT NULL,
c2 NUMBER,
c3 NUMBER
CREATE TABLE u.t4 (c1 NUMBER REFERENCES u.t1);
CREATE TABLE u.t5 (c1 NUMBER UNIQUE);
CREATE TABLE u.t6 (c1 NUMBER CHECK (c1 > 0));
CREATE TABLE u.t7 (c1 NUMBER NOT NULL);=================query========================
SELECT CASE
WHEN (SELECT COUNT (*)
FROM dba_tab_columns tc
WHERE tc.owner = o.owner AND tc.table_name = o.object_name) >
0
THEN
SUBSTR (
DBMS_METADATA.get_ddl (object_type, object_name, owner),
1,
INSTR (
DBMS_METADATA.get_ddl (object_type, object_name, owner),
CHR (10),
1,
2
+ (SELECT COUNT (*)
FROM dba_tab_columns tc
WHERE tc.owner = o.owner
AND tc.table_name = o.object_name)))
|| CASE
WHEN (SELECT COUNT (*)
FROM sys.obj$ so,
sys.cdef$ scd,
sys.con$ sc,
sys.user$ su
WHERE su.user# = so.owner#
AND so.obj# = scd.obj#
AND scd.con# = sc.con#
AND so.obj# = scd.obj#
AND scd.type# != 7
AND so.name = o.object_name
AND su.name = o.owner) = 0
THEN
',column5 number(3,0) default 0'
ELSE
'column5 number(3,0) default 0,'
END
|| SUBSTR (
DBMS_METADATA.get_ddl (object_type, object_name, owner),
INSTR (
DBMS_METADATA.get_ddl (object_type, object_name, owner),
CHR (10),
1,
2
+ (SELECT COUNT (*)
FROM dba_tab_columns tc
WHERE tc.owner = o.owner
AND tc.table_name = o.object_name)))
ELSE
DBMS_METADATA.get_ddl (object_type, object_name, owner)
END
t
FROM dba_objects o
WHERE owner = 'U';=================output========================
CREATE TABLE "U"."T1"
( "C1" NUMBER,
"C2" NUMBER,
"C3" NUMBER,
"C4" NUMBER,
column5 number(3,0) default 0,
PRIMARY KEY ("C1")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
TABLESPACE "USERS" ENABLE
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE UNIQUE INDEX "U"."SYS_C0025504" ON "U"."T1" ("C1")
PCTFREE 10 INITRANS 2 MAXTRANS 255
TABLESPACE "USERS" ;
CREATE TABLE "U"."T3"
( "C1" NUMBER NOT NULL ENABLE,
"C2" NUMBER,
"C3" NUMBER
,column5 number(3,0) default 0
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE TABLE "U"."T4"
( "C1" NUMBER,
column5 number(3,0) default 0,
FOREIGN KEY ("C1")
REFERENCES "U"."T1" ("C1") ENABLE
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE TABLE "U"."T2"
( "C1" NUMBER,
"C2" NUMBER,
"C3" NUMBER,
"C4" NUMBER
,column5 number(3,0) default 0
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE TABLE "U"."T5"
( "C1" NUMBER,
column5 number(3,0) default 0,
UNIQUE ("C1")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
TABLESPACE "USERS" ENABLE
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE UNIQUE INDEX "U"."SYS_C0025507" ON "U"."T5" ("C1")
PCTFREE 10 INITRANS 2 MAXTRANS 255
TABLESPACE "USERS" ;
CREATE TABLE "U"."T6"
( "C1" NUMBER,
column5 number(3,0) default 0,
CHECK (c1 > 0) ENABLE
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ;
CREATE TABLE "U"."T7"
( "C1" NUMBER NOT NULL ENABLE
,column5 number(3,0) default 0
) SEGMENT CREATION DEFERRED
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
TABLESPACE "USERS" ; -
Query help in regular expression
Hi all,
SELECT * FROM emp11
WHERE INSTR(ENAME,'A',1,2) >0;
Please let me know the equivalent query using regular expressions.
i have tried this after going through oracle regular expressions documentation.
SELECT * FROM emp11
WHERE regexp_LIKE(ename,'A{2}')
Any help in this regard would be highly appreciated .
Thanks,
P Prakashplease go here
Introduction to regular expressions ...
Thanks,
P Prakash -
Changeparticular characters in a string by using regular expressions ...
Hello Everyone,
I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
Is it possible by using regular expressions in oracle ?
Can you give me some clues ?
Thank youSSU wrote:
Hello Everyone,
I am trying to write a function by using oracles regular expression function REGEXP_REPLACE but I could not succed till now.
My problem as follows, I have a text in a column for example let say 'sdfsdf Sdfdfs Sdfd' I want replace all s and S characters with X and make the text look like 'XdfXdf XdfdfX Xdfd'.
Is it possible by using regular expressions in oracle ?
Can you give me some clues ?
Thank you
SQL> SELECT
2 regexp_replace('sdfsdf Sdfdfs Sdfd','s|S','X') from dual;
REGEXP_REPLACE('SD
XdfXdf XdfdfX XdfdRegards,
Achyut -
IR filter using "matches regular expression"
Hi,
I am familiar with Perl regular expressions, but I'm having trouble using the IR filter by regular expression in Apex.
For instance, I would like to search for dates of format 'MM/DD/YY' - can someone tell me how this would be done? I tried '[0-9](2)/[0-9](2)/[0-9](2)' and many other patterns to no avail.
Also can you point me to a good thread for regular expressions in Apex?
Thanks for any help.Hi,
you can play around with oracle regular expressions at
http://www.yocoya.com/apex/f?p=YOCOYA:REGEXP_HOME:0:
It's an Apex application, albeit "seasoned", where you can build and test the regex and it will be 100% compatible as it runs natively, so it's not simulated on a different platform.
Most likely the IR filter will make use of REGEXP_LIKE so you can pick that function from the menu.
Flavio
http://oraclequirks.blogspot.com
http://www.yocoya.com -
Regular expression - Replace not like
Hi All,
Is there a regexp pattern to replace anything other than 'oracle' from the below string.
"oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt"
The result will be "oracleoracleoracle"
If I want to write like regexp_replace('oracle sdsd oracle xyd fgh oracle idmdh asasas trtrt',<pattern>), what should be the pattern?
I know how to get the result by nesting regexp and other functions.
But is there any single pattern for this?
Thanks in advance.
Note; This is not a business requirement, trying to learn regexp..884476 wrote:
Could you please explain what does that pattern mean? We can look at your string as a sequence of substrings where each substring is set of characters (part A) followed by word oracle or, in last substring, by end-of-line (part B). Each of such substrings be want to replace with part B thus removing part A.
Dot (.) means any character. Asterisk (*) means repeated 0 or more times. This is our part A (I'll get back to ? later). Pipe (|) means OR. Dollar sigh ($) means end-of-line. Parenthesis mean grouping. So ((oracle)|$) means string oracle or end-of line. This is our part B. Now back to question mark. By default Oracle regular expressions are "greedy". We say any character repeated any number of times followed by word oracle. Since word oracle itself matched definition of any character repeated any number of times (6 in this case) regexp will match it that way that it will be from the beginning of the string to last occurrence of word oracle - that's why it is called "greedy". Question mark (?) tells regexp not to use greedy matching, therefore '.*?oracle' will stop at first occurrence of word oracle. Now replacement string. Notation \1 is grouping backreference. Group 1 is ((oracle)|$) and, as I already noted, means string oracle or end-of line (whichever was found).
SY. -
Hello All,
I come from Perl scripting language background. Perl's regular expressions are rock solid, robust and very fast.
Now I am planning to master Regular Expressions in Oracle.
Could someone please point the correct place to start with it like official Oracle documentation on Regular Expressions, any good book on Regex or may be any online link etc.
Cheers,
Parag
Edited by: Parag Kalra on Dec 19, 2009 11:03 AMHi, Parag,
Look under [R in the index of the SQL language manual|http://download.oracle.com/docs/cd/B28359_01/server.111/b28286/index.htm#R]. All the regular expression functions and operators start with "REGEXP", and there are a couple of entries under "regular expressions".
That applies to the Oracle 11 and 10.2 documentation. Regular expressions were hidden in the Oracle 10.1 SQL Language manual; you had to look up some similar function (like REGR_SYY, itself hidden under S for "SQL Functions", and then step through the pages one at a time.
Sorry, I don't know a good tutorial or introduction.
If you find something hopeful, please post a reference here. I think a lot of people would be interrested. -
Regular expressions in Oracle 9i
Hello,
Does oracle 9i support regular expressions?
I need to check if a varchar parameter contains only numbers OR letters, otherwise i should return false.
Thanks.Roger22 wrote:
Hello,
Does oracle 9i support regular expressions?
I need to check if a varchar parameter contains only numbers OR letters, otherwise i should return false.
Thanks.TRANSLATE is helpful to do such a check.
example
WITH testdata AS
(SELECT 'abcdef' txt FROM DUAL UNION ALL
SELECT '1234567' txt FROM DUAL union all
SELECT '0' txt FROM DUAL union all
SELECT '123a4567x00' txt FROM DUAL union all
SELECT '123.4567,00' txt FROM DUAL
select txt,
translate(txt,'a1234567890','a') numbers_removed,
translate(txt,'0abcdefghijklonopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','0') letters_removed
from testdata;
TXT NUMBERS_REMOVED LETTERS_REMOVED
abcdef abcdef
1234567 1234567
0 0
123a4567x00 ax 123456700
123.4567,00 ., 123.4567,00One idea is to check the result for NULL or to compare the length of similiar expressions.
Problems are usually special chars and how you want to handle that.
Edited by: Sven W. on Aug 11, 2010 11:07 AM
Edited by: Sven W. on Aug 11, 2010 11:07 AM -
Regular expressions in oracle 10 g
how to use regular expressions in oracle 10g forms
May be forms related question better answered in forms forum.
Forms -
Regular expression in oracle for hypen
Hi,
I want to match a word "{color:#993300}83-ASG{color}" using regexp_like and i used '{color:#993300}^83-*{color}' pattern to match this word but this also matches words like "{color:#993300}8307-YUF{color}". could anyone please tell me what pattern should i use to match words like {color:#993300}83-ASG{color}.
Also i need to know the similar pattern in oracle for the "{color:#993300}\b{}{color}" used in .net.
Thanks in advance.
PrasadHi Prasad,
Your regex could be as simple as '^83-'
So, not much use for a regular expression:
SQL> with test_data as (select '83-ASG' txt from dual union all
select '8307-YUF' from dual)
-- end of test data
select txt from test_data
where txt like '83-%'
TXT
83-ASG
1 row selected.Unless, you add some more value to it, perhaps like
SQL> with test_data as (select '83-ASG' txt from dual union all
select '8307-YUF' from dual)
-- end of test data
select txt from test_data
where regexp_like(txt, '^83-[[:upper:]]{3}$')
TXT
83-ASG
1 row selected.Regards
Peter -
Regular Expression/Replace - Oracle 7.3
Hi!
I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.
"Aaaa,Bbbb" --> "Aaaa, Bbbb"
REPLACE *",[0-9A-Za-z]"* WITH *", "*
The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
Any workaround for this?Hi,
Welcome to the forum!
kitsune wrote:
Hi!
I am trying the regular expression SQL functions of 10g to Oracle 7.3 and it seems the older version does not cover this feature yet.You're right; regular expressions only work in Oracle 10.1 and higher.
>
>
"Aaaa,Bbbb" --> "Aaaa, Bbbb"
REPLACE *",[0-9A-Za-z]"* WITH *", "*
The string pattern is to look for comma-punctuations that is not followed immediately by whitespacess so I can replace this with a comma followed by a whitespace.
Any workaround for this?You're best bet in Oracle 7.3 would be a user-defined function. That's a very old version; don't expect much.
Do you know anything else about the string? For example, is there some character (say ~) that never occurs in the string? Will there ever be two (or more) whitespace characters after punctuation? What characters do you consider to be whitespace? Which are punctuation? Depending on the answers, you might be able to do something with nested REPLACE and/or TRANSLATE functions. -
Regular expression vs oracle text performance
Does anyone have experience with comparig performance of regular expression vs oracle text?
We need to implement a text search on a large volume table, 100K-500K rows.
The select stmt will select from a VL, a view joining 2 tables, B and _TL.
We need to search 2 text columns from this _VL view.
Using regex seems less complex, but the deciding factor is of course performace.
Would oracle text search perform better than regular expression in general?
Thanks,
MargaretHi Dominc,
Thanks, we'll try both...
Would you be able to validate our code to create the multi-table index:
CREATE OR REPLACE PACKAGE requirements_util AS
PROCEDURE concat_columns(i_rowid IN ROWID, io_text IN OUT NOCOPY VARCHAR2);
END requirements_util;
CREATE OR REPLACE PACKAGE BODY requirements_util AS
PROCEDURE concat_columns(i_rowid IN ROWID, io_text IN OUT NOCOPY VARCHAR2)
AS
tl_req pjt_requirements_tl%ROWTYPE;
b_req pjt_requirements_b%ROWTYPE;
CURSOR cur_req_name (i_rqmt_id IN pjt_requirements_tl.rqmt_id%TYPE) IS
SELECT rqmt_name FROM pjt_requirements_tl
WHERE rqmt_id = i_rqmt_id;
PROCEDURE add_piece(i_add_str IN VARCHAR2) IS
lx_too_big EXCEPTION;
PRAGMA EXCEPTION_INIT(lx_too_big, -6502);
BEGIN
io_text := io_text||' '||i_add_str;
EXCEPTION WHEN lx_too_big THEN NULL; -- silently don't add the string.
END add_piece;
BEGIN
BEGIN
SELECT * INTO b_req FROM pjt_requirements_b WHERE ROWID = i_rowid;
EXCEPTION
WHEN NO DATA_FOUND THEN
RETURN;
END;
add_piece(b_req.req_code);
FOR tl_req IN cur_req_name(b_req.rqmt_id) LOOP
add_piece(tl_req.rqmt_name);
END concat_columns;
END requirements_util;
EXEC ctx_ddl.drop_section_group('rqmt_sectioner');
EXEC ctx_ddl.drop_preference('rqmt_user_ds');
BEGIN
ctx_ddl.create_preference('rqmt_user_ds', 'USER_DATASTORE');
ctx_ddl.set_attribute('rqmt_user_ds', 'procedure', sys_context('userenv','current_schema')||'.'||'requirements_util.concat_columns');
ctx_ddl.set_attribute('rqmt_user_ds', 'output_type', 'VARCHAR2');
END;
CREATE INDEX rqmt_cidx ON pjt_requirements_b(req_code)
INDEXTYPE IS CTXSYS.CONTEXT
PARAMETERS ('DATASTORE rqmt_user_ds
SYNC (ON COMMIT)');
Maybe you are looking for
-
Can we use batch management in repetitive manufacturing?
Can we use batch management in repetitive manufacturing? If not, can we use classification or something else? or what else options we have. Thnx!
-
when I try to load a new version of itunes on my windows XP pc I get a message that file MSVCR80.dll is missing as well as a windows error 126 message. any idea what to do?
-
Need Authority Check so that Do not display Customer in Production Order
Hi, I our business we use MTO in PP.Thats why Customer code with Customer Name is shown in Production Order General Tab.Now I want to restrict this view in production order so that no user can able to see the Customer Code and Name in production Orde
-
13" Retina MBP shutsdown no Crashlog
Hi there, since last week after installing the EFI firmware update 1.1 my MBP has been randomnly shutting off, there are no crashlogs after the restart, the screen will go black and will take sometimes up to 3 mins to start the computer again. My gue
-
Hi Everyone I love the MY TOP RATED feature on the nano - however, when I go to songs and reduce the rating, they still appear on "my top rated". . . how can i take them off of here? I still want them on my ipod, just not top rated anymore thanks sno