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.
Prasad
Hi 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
Similar Messages
-
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 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)'); -
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 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 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 not working for adobe forms
Hi,
Iam using qtp for adobe forms and for some reason if i put in regular expression for apid value it doesn't recognise the object..there is nothing wrong with the regular expression as it is evaluated using regular expression evaluator in qtp 11.0....any ideas
I got all the addins and everything and when i used regular expression for the top window it works but for any other object it doesn'tPlease try the code and see the problem. The regular expression is fine.
I can replace the string with these and got results like this:
import java.util.regex.Pattern;
public class HtmlFilter implements TextFilter {
private static String strTagPattern = "<\\s?(.|\n)*?\\s?>";
private static int patternMode = Pattern.MULTILINE | Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE | Pattern.CANON_EQ;
private static Pattern tagPattern = Pattern.compile(strTagPattern, patternMode);
public String filter(String t) {
if(t==null || t.length()==0) return "";
String ret = null;
return tagPattern.matcher(t).replaceAll("");
public static void main(String[] args) {
System.out.println(new HtmlFilter().filter(null));
System.out.println(new HtmlFilter().filter(""));
System.out.println(new HtmlFilter().filter("<P>abc def</P>"));
System.out.println(new HtmlFilter().filter("<P>我国石油供应安全系统影响</P>"));
}The results are
abc def
???????????? -
Regular expressions in JavaScript for CP5?
I'm having trouble implementing a regular expression from within the JavaScript window. First of all, does CP 5 support regular expressions?
On slide 1 I have a Text Entry Box, (called TheTeb) with a Submit button. TheTeb has variable associated with it called TypedText.
In the box, the user may type anything.
On slide 2 there is a caption.
The caption must show the text that the user typed into TheTeb but filtered so that only the letters, numbers, and spaces can be shown.
For example,
if the user types: 123 & abc /DEF
the caption will show: 123 abc DEF
This requirement is represents the behavior of an application that I am simulating, so I don't want to change the interaction in any way.
My strategy is to use 2 different variables, one for the text entry box (TypedText), the other for the caption (FilteredText). I can add JavaScript to the On Enter event of slide 2. The script will Get the TypedText, pass the TypedText to FilteredText, and run a regular expression somewhere so the filtered text displays on slide 2.
Here's the script so far:
var objCP = document.Captivate;
var ScriptTypedText = objCP.cpEIGetValue('TypedText');
function ReturnValue(){
objCP.cpEISetValue('FilteredText', ScriptTypedText);
ReturnValue();
The script works as is. The user types text on slide 1 (as TypedText), presses Enter and the text shows up on slide 2 (as $$FilteredText$$). Obviously, the trouble is, I don't know where to add my regular expression into the JavaScript so the text actually gets filtered. Do I make a new function?
By the way, a sort of pseudocode syntax for the expression would be:
FilteredText = TypedText.replace(/ /g,""); -
Regular Expression item validation for email address
Hi,
Does anyone know of a regular expression I can use to validate an email address field? I am using Apex 3.2.
Your help would be much appreciated.
Thanks,
ca84^((\s*[a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4}\s*[,;:]){1,100}?)?(\s*[a-zA-Z0-9\._%-]+@[a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})*$
-
Data generation using regular expression in c# for sql server
Hello Everybody,
I am using VS 2013 professional, SQL Server 2012.
I am writing database application in c#. I have a table which stores starttime and endtime of operator
As starting step, I inserted random DateTime into the table.
But i would like hide some Patterns inside the database like it should insert some records that operator2 is absent on every second tuesday in every month in 2014 between 3AM to 4AM.
How do i tell my c# code to insert that Patterns into databse. From some posts I understtod that it may be done by using regular expressions. But i did not find clear example.
Could someone please tell me how to do it?
Thank you so much.I'm not sure what exactly you're referring to, but I think you may be able to accomplish some of what you want by using triggers, constraints, and column defaults. These are database objects that are defined by using DDL, so have a look at the DDL reference
(and other information about these objects) in SQL Server Books Online and see if these will do what you want. T-SQL implements a "pattern-wildcard language" that is not the same as regular expressions.
In addition you can write SQLCLR objects (e.g. triggers and functions) that can use the .NET regular expression library, which is an implementation of the well-known regular expression library. There are a number of examples of SQLCLR/regular expressions
around, a simple web search should suffice.
Hope this helps, Bob -
ReplaceAll string by regular expression not work for this case.
I will delete all tag and want "pure text" but the output is delete all.
String content = "<aaa>pure text<fff>";
content = content.replaceAll("<.*>","");Content has output is blank because reqular expression match from begin and end of string
But when i change
String content = "<aaa>pure text<fff";
content = content.replaceAll("<.*>","");The output is ==> pure text<fff
How make req match in sequential
Please lead me to solutionpeterdog1234 wrote:
Thank you very much.
I know '?' is a Quantifiers.
I do not understand using ?
Please lead me againSee the paragraph "Laziness Instead of Greediness" from [http://www.regular-expressions.info/repeat.html]. -
Without using a regular expressions in oracle 9i
dear all;
I have the following test data below
insert into p
(id)
values
('\G1\G2');
insert into p
(id)
values
('\A1\');
insert into p
(id)
values
('\B1\B2\B3');
insert into p
(id)
values
('\J1\J2\J3\J4');and this is the output I desire though
ID
G1
null
B2
J3the output is gotten by looking at the second to the last entry and extracting it....
so for \G1\G2 the second to the last entry was G1 hence we have G1
for \A1\ there is no second to the last entry and that is why it is null
for \B1\B2\B3 the second to the last entry was B2Hi,
user13328581 wrote:
... the output is gotten by looking at the second to the last entry and extracting it....
so for \G1\G2 the second to the last entry was G1 hence we have G1
for \A1\ there is no second to the last entry and that is why it is nullSo backslashes at the end of id don't matter. Whether id is
'\AI',
'\A1\' or
'\A1\\\\\\\\\\\\'
there's only entry in id, and so you want to return NULL. Is that right?
Here's one way to do that in Oracle 9:
WITH got_pos AS
SELECT id
, INSTR ( RTRIM (id, '\')
, -1
, 2) + 1 AS pos_from
, INSTR ( RTRIM (id, '\')
, -1
, 1) AS pos_to
FROM p
SELECT id
, CASE
WHEN pos_from > 1
THEN SUBSTR ( id
, pos_from
, pos_to - pos_from
END AS penult
FROM got_pos
ORDER BY id
; -
Simple regular expression in oracle query
hi guys, I have this challenge.
say I have a query:
select name, user_name, object_type from questions;
now, for the column object type, I can get values that end in 'Q' followed by number.
So object type columns can be 00Q1, ABCQ2, 56Q7 e.t.c. It can be any number really.
The thing is, I want to add a small grouping, so that for the rows which have the object type column ending in Q followed by number, I can have an additional column whose value changes to question.
So the query now becomes:
select name, user_name, object_type, column_type from questions;
So column_type can be question if object type ends with Q and a number, otherwise just give it a default value, like Others or something.
Is this possible and if so how can I please achieve it.
Thanks very much.Hope this will help.
SQL> with t as
2 ( select '00Q1' element_name from dual union all
3 select 'ABCQ2' from dual union all
4 select '56QA7 ' from dual union all
5 select '56Q7 ' from dual union all
6 select 'ABCQA' from dual)
7 select * from t
8 where regexp_like(element_name,'\Q[0-9]')
9 /
ELEMEN
00Q1
ABCQ2
56Q7Or something like this
SQL> with t as
2 ( select '00Q1' element_name from dual union all
3 select 'ABCQ2' from dual union all
4 select '56QA7 ' from dual union all
5 select '56Q7 ' from dual union all
6 select 'ABCQA' from dual)
7 select t.*, DECODE(regexp_instr(element_name,'\Q[0-9]'),0,'Not Found',element_name ) comments
8 from t
9 /
ELEMEN COMMENTS
00Q1 00Q1
ABCQ2 ABCQ2
56QA7 Not Found
56Q7 56Q7
ABCQA Not FoundEdited by: Saubhik on May 18, 2010 6:41 AM -
Regular expression not working for String.split()?
hi, i have a String variable called 'table'.
It has a bunch of chunks of data seperated by whitespace, whether it
be spaces or carraige returns. Anyways, i want to split this up using
the String.split function. i want to split it around whitespace.
here is my code:
String codes[] = table.split("\s");
However, i'm getting back all nulls in the codes variable. What am i doing wrong?
thankssplit("\\s")\ is special both in Java String literals and in regex, so you need two of them.
You'll probably also have to take an extra step it you don't want regex to stop at newlines. I forget the details, so check the docs. -
Regular Expression to check for some of the special characters
Can someone please provide me a RegularExpression to check if a string contains any of the speical characters i.e. *!@#$%^&*()_+ []{}:;',./<>?~`*
Thanks
Edited by: whitesox12 on Apr 3, 2008 9:46 PM[*!@#$%\^&()_+\[\]{}:;',./?~`]In a Java string literal, a backslash should be written as two consecutive backslashes.
Maybe you are looking for
-
How can I get back a pages file and its backup if I did not save them to my documents?
Hallo community! My mac got stock on a website because of a java update so I was forced to shut down the computer using the on-botton. Upon restarting my work on Pages I clicked on the file I was working on so as to open both the file and pages but t
-
HT4527 How do I transfer all my iPod songs to my new touch iPod
How do I transfer all my iPod songs to my new touch iPod
-
Hi, I'm trying to use suspend&resume plugs in a WDA application to call an external ITS Service and then to go back to my application by clicking BACK button in the browser. the url that I try to call is http://zzzzz:1111/sap/bc/gui/sap/its/BBPMAININ
-
Downloaded Master Suite 5 - get error -4960 when I try an install in
I have a Mac thats only a few weeks old with CS4 versions of dreamweaver, illustrator and Photoshop I have tried installing direct from hte Adopbe installer, and by locating the .dmg and get the same error? Thanks Gemma
-
HT2484 Is iSync working with OS X Lion?
Is iSync working with OS X Lion?