Generating values using Regular Expression
Can values be generated using Regular Expreession?
I want to generate unique string values on the fly using secified Regular Expression.
Thanx in advance.
Message was edited by:
Kaustubh
i do not know if there is something that can do it automatically but let's say you have the following regex:
"a number of 5 digits" then "2 letters" then "a hyphen" and then "a digit"
what you can do is something like that:
define the vars that will allows you to pick a value for each part of the generated value
this means you will have:
final int[] DIGITS = new int[]{0;1;2;3;4;5;6;7;8;9};
final char[] LETTERS = new char[]{'a', 'b', ... 'z'};
final char HYPHEN = '-';
once you have those vars, all you have to do is to use "Random" class to retrieve a random value from DIGITS and LETTERS
append them all in the correct order , without forgetting to append the HYPHEN and you have your value
Similar Messages
-
How to get year value using regular expression
Hi,
I have a different format of date such as 2004-01-03, 2003/01, 05/06/2005, 06-05-2007
How can I get only the year value using regular expression? The year value is always in 4 digits
Thanks in advancesabre150 wrote:
JosAH wrote:
\d{4}Is this the Jos I knew who poured scorn on anything to do with regex? Is this the Jos I knew who said that the 'pimping lemon' stopped regex being of any real use?It wasn't me; honest, I'm innocent: one of my parrots walked over my keyboard; I wouldn't be able to type such nonsense; naughty parrot! No cookie!
kind regards,
Jos
ps. regexes can only survive the baby-pumping-lemma; they all die a horrible death with the real-men-pumping lemma! So there. -
How to use regular expressions to generate test data ?
Hi
Someone can help me on what I have to do in order to create test data with regular expressions ?
For example, I want to introduce a random telephone number (XXX-XXXX) in the phone number Form Field, I want to create the phone number using regular expressions in order to test different values in each playback of the script.
I don't want to use VB or vbscript in e-tester, I'm just trying to do this with e-load nav editor and e-load
Thanks a lotHi and thanks for your answer!, it's a great trick ^_^
I'm doing a research on how to improve the execution speed of the scripts in e-load, so actually I'm trying to avoid the use of databanks and VB code also.
I was expecting that maybe e-load, e-load nav editor or e-tester can automatically generate test data via Regular Expressions. Someone Knows if this is possible ?
Also can anyone tell me what the option "Automatically Generated (complex)" means ? I think that this will help me a lot
*you can find this option in e-load Nav Editor when you select a parameter in the tree view, then go to the "type" listbox in the properties pane, there you will find this option and some more options like :"Databanked variable", "Custom Dynamic Value", "Function".. etc.
Thanks again -
Using regular expressions for validating time fields
Similar to my problem with converting a big chunk of validation into smaller chunks of functions I am trying to use Regular Expressions to handle the validation of many, many time fields in a flexible working time sheet.
I have a set of FormCalc scripts to calculate the various values for days, hours and the gain/loss of hours over a four week period. For these scripts to work the time format must be in HH:MM.
Accessibility guidelines nix any use of message box pop ups so I wanted to get around this by having a hidden/visible field with warning text but can't get it to work.
So far I have:
var r = new RegExp(); // Create a new Regular Expression Object
r.compile ("^[00-99]:\\] + [00-59]");
var result = r.test(this.rawValue);
if (result == true){
true;
form1.flow.page.parent.part2.part2body.errorMessage.presence = "visible";
else (result == false){
false;
form1.flow.page.parent.part2.part2body.errorMessage.presence = "hidden";
Any help would be appreciated!Date and time fields are tricky because you have to consider the formattedValue versus the rawValue. If I am going to use regular expressions to do validation I find it easier to make them text fields and ignore the time patterns (formattedValue). Something like this works (as far as my very brief testing goes) for 24 hour time where time format is HH:MM.
// form1.page1.subform1.time_::exit - (JavaScript, client)
var error = false;
form1.page1.subform1.errorMsg.rawValue = "";
if (!(this.isNull)) {
var time_ = this.rawValue;
if (time_.length != 5) {
error = true;
else {
var regExp = /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/;
if (!(regExp.test(time_))) {
error = true;
if (error == true) {
form1.page1.subform1.errorMsg.rawValue = "The time must be in the format HH:MM where HH is 00-23 and MM is 00-59.";
form1.page1.subform1.errorMsg.presence = "visible";
Steve -
Using Regular Expressions to replace Quotes in Strings
I am writing a program that generates Java files and there are Strings that are used that contain Quotes. I want to use regular expressions to replace " with \" when it is written to the file. The code I was trying to use was:
String temp = "\"Hello\" i am a \"variable\"";
temp = temp.replaceAll("\"","\\\\\"");
however, this does not work and when i print out the code to the file the resulting code appears as:
String someVar = ""Hello" i am a "variable"";
and not as:
String someVar = "\"Hello\" i am a \"variable\"";
I am assumming my regular expression is wrong. If it is, could someone explain to me how to fix it so that it will work?
Thanks in advance.Thanks, appearently I'm just doing something weird that I just need to look at a little bit harder.
-
How to fetch substring using regular expression
Hi,
I am new to using regular expression and would like to know some basic details of how to use them in Java.
I have a String example= "http://www.google.com/foobar.html#*q*=database&aq=f&aqi=g10&fp=c9fe100d9e542c1e" and would like to get the value of "q" parameter (in bold) using regular expression in java.
For the same example, when we tried using javascript:
match = example.match("/^http:\/\/(?:(?!mail\.)[^\.]+?\.)?google\.[^\?#]+(?:.*[\?#&](?:as_q|q)=([^&]+))?/i}");
document.write('
' + match);
We are getting the output as: http://www.google.com/foobar.html#q=database,*database* where the bold text is the value of "q" parameter.
In Java we are trying to get the value of the q parameter separately or atleast resembles the output given by JavaScript. Please help me resolving this issue.
Regards
PraveenBalusC wrote:
Regex is a cumbersome solution for fixed patterns like URL's. String#substring() in combination with String#indexOf would most likely already suffice.I usually agree, although, in this case, finding the exact parameter might be difficult without a small regex, perhaps:
"\\wq=\\s*"in conjunction with Pattern/Matcher, used similarly to an indexOf() to find the start of the parameter value.
Winston -
Requirement to update a column by using Regular Expression
Hi All,
I have a requirement to update a column which is having values like below code.
based on the conditinos I need to update from ‘E’ to ‘Z’. Few positions I need to update and remaining positions I need leave as it is.
How I can achive this requirement by using regular expression regexp_replace.
Actual value --> 'AEAAAEAA EE AA EE AA EE EEEAA AA AA '
After update --> 'AZAAAZAA EE AA EE AA EE EEEAA AA AA 'below is my requirement. I am adding the conditions dynamically as per the conditions. I dont know the position of the E. If 'E' is in any position I need to update with 'Z' if that 'E' satisfy the condition.
I dont want to update all the E's to Z's.
I want to update specific E's which satisfy the condition.
IF l_kwhhilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,1,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\1';
END IF;
IF l_kwhilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,2,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\2';
END IF;
IF l_kvahilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,3,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\3';
END IF;
IF l_kvarhilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,4,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\4';
END IF;
IF l_todkwh1hilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,5,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\5';
END IF;
IF l_todkwh2hilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,6,1) = ''E'' OR ';
l_exp := l_exp||'Z';
ELSE
l_exp := l_exp||'\6';
END IF;
l_exp := ''''||l_exp||'''';
l_exp1 := '\1\2\3\4'||l_exp1;
IF l_todkw1hilow >= 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,11,1) = ''E'' OR ';
l_exp1 := l_exp1||'Z';
ELSE
l_exp1 := l_exp1||'\5';
END IF;
IF l_todkw2hilow = 1 THEN
l_where := l_where||' SUBSTR(OVERRIDEFIELD,12,1) = ''E'' OR ';
l_exp1 := l_exp1||'Z';
ELSE
l_exp1 := l_exp1||'\6';
END IF;
l_exp1 := ''''||l_exp1||'''';
IF i give 10 in the regexp_replace it is not working.
SET OVERRIDEFIELD = REGEXP_REPLACE(SUBSTR(overridefield,1,6), ''(.)(.)(.)(.)(.)(.)'','||l_exp||')'||
' ||REGEXP_REPLACE(SUBSTR(overridefield,7,6), ''(.)(.)(.)(.)(.)(.)'','||l_exp1||')'||
' ||SUBSTR(overridefield,13)'|| -
Extract values with Regular Expression
How to extract values into [ ] using regular expression.
With data As
Select 'AAAAAA[10] AAA: 19C' Txt From Dual Union all
Select 'XX[450]-10A' Txt From Dual Union all
Select '[5]AVC19C' Txt From Dual Union all
Select 'FVD[120]D2AC' Txt From Dual
)I hope this return
10
450
5
120Thanks in advanceduser11118871 wrote:
Thanks for all.
Hi BluShadow, can you explain what this is doing!?
ThanksSure.
Search for ----------------| /------- Replace the found pattern in the search string with backreference 1
/------------\ /\ (the first thing backreferenced in the search string)
regexp_replace(txt, '^.*\[(.*)\].*$','\1')
|\/\/\--/\/\/|
| \ \ / \ \|
| | | | | |\- End of string
| | | | | |
| | | | | \- Any number of characters
| | | | |
| | | | \- Right square bracket (escaped)
| | | |
| | | \- any characters (backreferenced by round brackets)
| | |
| | \- Left square bracket (escaped)
| |
| \- Any number of characters
|
\- Start of stringEdited by: BluShadow on Jun 29, 2009 2:19 PM -
I do have a table with one varchar2 column with the following values:
COL_NAME
1.1.3.TECH.SG.1.Action.2
1.1.3.TECH.SG.1.Action.3
1.1.3.TECH.SG.1.Action.4
1.1.3.TECH.SG.1.Action.5
1.1.3.TECH.SG.1.Action.6
I need the last digit to be reduced by 1 like below:
COL_NAME NEW_VALUE
1.1.3.TECH.SG.1.Action.2 1.1.3.TECH.SG.1.Action.1
1.1.3.TECH.SG.1.Action.3 1.1.3.TECH.SG.1.Action.2
1.1.3.TECH.SG.1.Action.4 1.1.3.TECH.SG.1.Action.3
1.1.3.TECH.SG.1.Action.5 1.1.3.TECH.SG.1.Action.4
1.1.3.TECH.SG.1.Action.6 1.1.3.TECH.SG.1.Action.5
How can this be achieved by a SQL statement using Regular Expression ?
Pls suggest.
Regards
MSYou don't really need regexps, you can just use normal instr() and substr():
1 with v as (
2 select '1.1.3.TECH.SG.1.Action.2' as val from dual union all
3 select '1.1.3.TECH.SG.1.Action.3' as val from dual union all
4 select '1.1.3.TECH.SG.1.Action.4' as val from dual union all
5 select '1.1.3.TECH.SG.1.Action.5' as val from dual union all
6 select '1.1.3.TECH.SG.1.Action.6' as val from dual
7 )
8 select val
9 , substr(val, 1, instr(val, '.', -1))
10 || to_char(to_number(substr(val, instr(val, '.', -1) + 1)) + 1) new_val
11* from v
SQL> /
VAL NEW_VAL
1.1.3.TECH.SG.1.Action.2 1.1.3.TECH.SG.1.Action.3
1.1.3.TECH.SG.1.Action.3 1.1.3.TECH.SG.1.Action.4
1.1.3.TECH.SG.1.Action.4 1.1.3.TECH.SG.1.Action.5
1.1.3.TECH.SG.1.Action.5 1.1.3.TECH.SG.1.Action.6
1.1.3.TECH.SG.1.Action.6 1.1.3.TECH.SG.1.Action.7
5 rows selected.cheers,
Anthony -
Pattern matching using Regular expression
Hi,
I am working on pattern matching using regular expression. I the table, I have 2 columns A and B
A has value 'A499BPAU4A32A386KBCZ4C13C41D20E'
B has value like '*CZ4*M11*7NQ+RDR+RSM-R9A-R9B'
the requirement is that I have to match the columns of B in A. If there is a value with * sign, this must be present in A like 'CZ4' should exit in string A.
The issue I am facing is that there are 2 values with * sign. The code works fine for first match (CZ4) but it does not look further as M11 does not exist in A.
I used the condition
AND instr(A,substr(REGEXP_SUBSTR(B, '*[^*]{3}'),2) ,1)=0
First of all, is this possible to match multiple patterns in one condition?
If yes, please suggest.
Thanksuser2544469 wrote:
Thanks a lot Frank. This query worked wonderful for the test data I have provided however I have some concerns:
- query doesnot include the column BOOK which is a mandatory check.Sorry, that was my mistake. It was a very easy mistake to make, since you posted sample data where it didn't matter. Instead of doing a cross-join between vn and got_must_have_cnt, do an inner join, using book. That means book will have to be in got_must_have_cnt, and all the sub-queries from which it descends. Look for comments that say "March 22".
If you want to treat '+' in test_cat.codes as '*', then the simplest thing is probably just to use REPLACE, so that when the table has '+', you use '*' instead.
WITH got_token_cnt AS
SELECT cat
, book -- Added March 22
, REPLACE (codes, '+', '*') AS codes -- If desired. Changed March 22
, LENGTH (codes) - LENGTH ( TRANSLATE ( codes
, 'x*+-'
, 'x'
) AS token_cnt
FROM test_cat
, cntr AS
SELECT LEVEL AS n
FROM ( SELECT MAX (token_cnt) AS max_token_cnt
FROM got_token_cnt
CONNECT BY LEVEL <= max_token_cnt
, got_tokens AS
SELECT t.cat
, t.book -- Added March 22
, REGEXP_SUBSTR ( t.codes
, '[*+-]'
, 1
, c.n
) AS token_type
, SUBSTR ( REGEXP_SUBSTR ( t.codes
, '[*+-][^*+-]*'
, 1
, c.n
, 2
) AS token
FROM got_token_cnt t
JOIN cntr c ON c.n <= t.token_cnt
, got_must_have_cnt AS
SELECT cat, book -- Changed March 22
, COUNT (CASE WHEN token_type = '*' THEN 1 END) AS must_have_cnt
FROM got_tokens
GROUP BY cat, book -- Changed March 22
SELECT mh.cat
, vn.vn_no
FROM got_must_have_cnt mh
JOIN vn ON mh.book = vn.book -- Changed March 22
LEFT OUTER JOIN got_tokens gt ON mh.cat = gt.cat
AND INSTR (vn.codes, gt.token) > 1
GROUP BY mh.cat
, mh.must_have_cnt
, vn.vn_no
HAVING COUNT (CASE WHEN gt.token_type = '*' THEN 1 END) = mh.must_have_cnt
AND COUNT (CASE WHEN gt.token_type = '-' THEN 1 END) = 0
ORDER BY mh.cat
- query is very slow with 60000 records in vn table. Cost is somewhere around 36000.See these threads:
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
Relational databases were designed to have (at most) one piece of information in each column. If you decide to have multiple items in the same column (as you have a variable number of tokens in the codes column), don't be surprised if that makes things slower and more complicated. Most of the query I posted, and perhaps most of the time needed, is jsut to normalize the data. If you stored the data in a narmalized form, perhaps something like got_tokens, then you wouldn't need the first 3 sub-queries that I posted.
Edited by: Frank Kulash on Mar 22, 2011 12:04 PM -
Searching for a substring using Regular Expression
I have a lengthy String similar to repetetion of the one below
String str="<option value='116813070'>Something1</option><option value='ABCDEF' selected>Something 2</option>"I need to search for the Sub string "<option value='ABCDEF' selected>" (need to get the starting index of sub string) and but the value ABCDEF can be anything numberic with varying length.
Is there any way i can do it using regular expressions(I have no other options than regular expression)?
thanks in advance.If you go through the tutorial then you will find this on the second page:
import java.io.Console;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class RegexTestHarness {
public static void main(String[] args){
Console console = System.console();
if (console == null) {
System.err.println("No console.");
System.exit(1);
while (true) {
Pattern pattern =
Pattern.compile(console.readLine("%nEnter your regex: "));
Matcher matcher =
pattern.matcher(console.readLine("Enter input string to search: "));
boolean found = false;
while (matcher.find()) {
console.format("I found the text \"%s\" starting at " +
"index %d and ending at index %d.%n",
matcher.group(), matcher.start(), matcher.end());
found = true;
if(!found){
console.format("No match found.%n");
}It's does everything you need and a bit more. Adapt it to your needs then write a regular expression. Then if you have problems by all means come back and post them up here, but first at least attempt to solve it yourself. -
ADF Email Validation using Regular Expression
Hi,
Wanted to add Email Validation VO search.
It is working if i put
<af:validateRegExp pattern="[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}"
messageDetailNoMatch="The value {1} is not a valid email address:"/>However this requires email id to be entered in Capital Letters.
Tried with below option is not working.
<af:inputText value="#{bindings.xxEmail.inputValue}" label="Email"
required="#{bindings.xxEmail.hints.mandatory}"
columns="#{bindings.xxEmail.hints.displayWidth}"
maximumLength="#{bindings.xxEmail.hints.precision}"
shortDesc="#{bindings.xxEmail.hints.tooltip}" id="it5">
<f:validator binding="#{bindings.xxEmail.validator}"/>
<f:validateLength minimum="6"/>
<af:validateRegExp pattern="[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}"
messageDetailNoMatch="The value {1} is not a valid email address:"/>
</af:inputText>I got above info from
ADF Email Validation using Regular Expression
User don't enter email id Without @ .
Kindly suggest pattern to achive this.
Thanks,
jit
Edited by: appsjit on Jan 25, 2013 7:08 PMThe RegEx to check EMail after RFC2822
[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?There are still some missing parts in the check as not all suffix combinations are allowed, but this is pretty good.
Timo -
Date Validation (yyyy/MM/dd) Using Regular Expression
Hi Friends,
I want to validate date entered by user in yyyy/MM/dd format and for this I want to use Regular Expressions only. Also is there any tool that can be used to generate Regular Expression (for Win2000, Win NT)?
Regards,
Himanshu Rathoretry this
public class Test
public static void main(String [] args)
String regex = "\\d{4}/[01]\\d/[0-3]\\d";
System.out.println("2003/12/11".matches(regex));
System.out.println("2djd/kj3".matches(regex));
System.out.println("22/12/12".matches(regex));
System.out.println("2003/23/05".matches(regex));
System.out.println("1999/12/51".matches(regex));
System.out.println("2007/05/07".matches(regex));
}i'm not able to try on it because i only have jdk1.3.1 installed on my computer and these codes
required j2sdk1.4 -
Request some help, over procedure's performance uses regular expressions for its functinality
Hi All,
Below is the procedure, having functionalities of populating two tables. For first table, its a simple insertion process but for second table, we need to break the soruce record as per business requirement and then insert into the table. [Have used regular expressions for that]
Procedure works fine but it takes around 23 mins for processing 1mm of rows.
Since this procedure would be used, parallely by different ETL processes, so append hint is not recommended.
Is there any ways to improve its performance, or any suggestion if my approach is not optimized? Thanks for all help in advance.
CREATE OR REPLACE PROCEDURE SONARDBO.PRC_PROCESS_EXCEPTIONS_LOGS_TT
P_PROCESS_ID IN NUMBER,
P_FEED_ID IN NUMBER,
P_TABLE_NAME IN VARCHAR2,
P_FEED_RECORD IN VARCHAR2,
P_EXCEPTION_RECORD IN VARCHAR2
IS
PRAGMA AUTONOMOUS_TRANSACTION;
V_EXCEPTION_LOG_ID EXCEPTION_LOG.EXCEPTION_LOG_ID%TYPE;
BEGIN
V_EXCEPTION_LOG_ID :=EXCEPTION_LOG_SEQ.NEXTVAL;
INSERT INTO SONARDBO.EXCEPTION_LOG
EXCEPTION_LOG_ID, PROCESS_DATE, PROCESS_ID,EXCEPTION_CODE,FEED_ID,SP_NAME
,ATTRIBUTE_NAME,TABLE_NAME,EXCEPTION_RECORD
,DATA_STRUCTURE
,CREATED_BY,CREATED_TS
VALUES
( V_EXCEPTION_LOG_ID
,TRUNC(SYSDATE)
,P_PROCESS_ID
,'N/A'
,P_FEED_ID
,NULL
,NULL
,P_TABLE_NAME
,P_FEED_RECORD
,NULL
,USER
,SYSDATE
INSERT INTO EXCEPTION_ATTR_LOG
EXCEPTION_ATTR_ID,EXCEPTION_LOG_ID,EXCEPTION_CODE,ATTRIBUTE_NAME,SP_NAME,TABLE_NAME,CREATED_BY,CREATED_TS,ATTRIBUTE_VALUE
SELECT
EXCEPTION_ATTR_LOG_SEQ.NEXTVAL EXCEPTION_ATTR_ID
,V_EXCEPTION_LOG_ID EXCEPTION_LOG_ID
,REGEXP_SUBSTR(str,'[^|]*',1,1) EXCEPTION_CODE
,REGEXP_SUBSTR(str,'[^|]+',1,2) ATTRIBUTE_NAME
,'N/A' SP_NAME
,p_table_name
,USER
,SYSDATE
,REGEXP_SUBSTR(str,'[^|]+',1,3) ATTRIBUTE_VALUE
FROM
SELECT
REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
FROM
DUAL t1 CROSS JOIN
TABLE
CAST
MULTISET
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
AS SYS.odciNumberList
) t2
WHERE REGEXP_SUBSTR(str,'[^|]*',1,1) IS NOT NULL
COMMIT;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RAISE;
END;
Many Thanks,
ArpitRegex's are known to be CPU intensive specially when dealing with large number of rows.
If you have to reduce the processing time, you need to tune the Select statements.
One suggested change could be to change the following query
SELECT
REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,t2.COLUMN_VALUE) str
FROM
DUAL t1 CROSS JOIN
TABLE
CAST
MULTISET
SELECT LEVEL
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
AS SYS.odciNumberList
) t2
to
SELECT REGEXP_SUBSTR(P_EXCEPTION_RECORD, '([^^])+', 1,level) str
FROM DUAL
CONNECT BY LEVEL <= REGEXP_COUNT(P_EXCEPTION_RECORD, '([^^])+')
Before looking for any performance benefit, you need to ensure that this does not change your output.
How many substrings are you expecting in the P_EXCEPTION_RECORD? If less than 5, it will be better to opt for SUBSTR and INSTR combination as it might work well with the number of records you are working with. Only trouble is, you will have to write different SUBSTR and INSTR statements for each column to be fetched.
How are you calling this procedure? Is it not possible to work with Collections? Delimited strings are not a very good option as it requires splitting of the data every time you need to refer to. -
One for the Tekkies: How to get this output using REGULAR EXPRESSIONS?
How to get the below output using REGULAR EXPRESSIONS??
SQL> ed
Wrote file afiedt.buf
1* CREATE TABLE cus___addresses (full_address VARCHAR2(200 BYTE))
SQL> /
Table created.
SQL> PROMPT Address Format is: House #/Housename, street, City, Zip Code, COUNTRY
House #/Housename, street, City, Zip Code, COUNTRY
SQL> INSERT INTO cus___addresses VALUES('1, 3rd street, Lansing, MI 49001, USA');
1 row created.
SQL> INSERT INTO cus___addresses VALUES('3B, fifth street, Clinton, OK 74103, USA');
1 row created.
SQL> INSERT INTO cus___addresses VALUES('Rose Villa, Stanton Grove, Murray, TN 37183, USA');
1 row created.
SQL> SELECT * FROM cus___addresses;
FULL_ADDRESS
1, 3rd street, Lansing, MI 49001, USA
3B, fifth street, Clinton, OK 74103, USA
Rose Villa, Stanton Grove, Murray, TN 37183, USA
SQL> The REG EXP query shouLd output the ZIP codes: i.e. 49001, 74103, 37183 in 3 rows.Edited by: user12240205 on Jun 18, 2012 3:19 AMHi,
user12240205 wrote:
... Frank, ʃʃp's method, I understand. But your method, although correct, I find it difficult to understand.
Could you explain how you did this?? What does '.*(\d{5})\D*' and '\1' mean???
Your method is better because it uses only ONE reg expression function. ʃʃp's uses 2.In Oracle 10.2 (I believe) and higher, '\d' is equivalent to '[[:digit:]]', and '\D' is equivalent to '[^[:digit:]]'. I find '\d' and '\D' easier to type, but there's nothing wrong with using '[[:digit:]]' and '[^[:digit:]]'.
'.*' means "0 or more of any character".
'\D*' means "0 or more non-digits".
The whole expression, '.*(\d{5})\D*' means:
a. 0 or more characters (any characters)
b. 5 digits
c. 0 or more non-digits.
'\1' is a Backreference . It means the sub-string that matched the pattern after the 1st '(', up to (but not including) its matching ')'. In this case, that means the sub-string that matched '\d{5}', or b. using the explanation immediately above.
So the entire REGEXP_REPLACE call means "When you see a sub-string consisting of a., follwed immediately by b., followed immedately by c., replace that sub-string with b. alone."
Maybe you are looking for
-
Hi There, I have locked the restricted access section as she was purchasing lots of in app purchases and now I cannot remember the four digit code to unlock it. Does anyone know how if there is a master code or how to reset only this section without
-
Bulging 17 inch Mac Book Pro Rechargeable Battery A1189 10.8V 68WH
Good Day; My battery has been swelling up over the past 2 weeks, and the apple store I visited don't take it or advise. I don't have a receipt because I bought the system used and the owner told me it has a new battery (just over a year old now), so
-
I broke my iPhone and now using my grandson's old iphone 3. I inserted my sim and it works but when I plug into the computer, iTune's still recognizes the phone as my grandson's phone and won't recognize my music and apps on iTunes. How do I fix this
-
Hello All, I am trying to set up Vendor specific tolerance to put a control on Invoice posting I have made following Config setting MM->Logistic invoice verification -> Incoming Invoice ->Configure vendor specific tolerances. Created tolerance group
-
Radio playlist is not in sync with the currently playing field
Hi, I am using the radio function a lot.This means that I am using the vote funtion in order to "optimize" my radio plalist.But often it shows different songs as you can see in the attached picture. Does anyone know whats wrong with it?I have already