Procedure using regular expression
How to write a procedure using regular expression where i pass a string as input
The procedure should check whether it is a valid email address or not
Please help me
Hello,
perhaps you don't need to code it, because it's already there.
When you use the database to send your mails it or the appropriate package throws the exception
ORA-29279: Permanenter SMTP-Fehler: 501 5.5.4 Invalid Address
When you just need a procedure to check it you can write a wrapper for a java function.
import javax.mail.internet.*;
import oracle.sql.NUMBER;
public class mail_utility {
public static NUMBER validate_address(String rfc822Address) {
int rc = 0;
try {
InternetAddress ia = new InternetAddress(rfc822Address);
rc = 1;
} catch (AddressException ae) {
rc = 0;
} catch (Exception e) {
rc = -1;
} finally {
return new NUMBER(rc);
CREATE OR REPLACE FUNCTION VALIDATE_ADDRESS (p_address in varchar2)
return number
as language java name
'mail_utility.validate_address(java.lang.String) return oracle.sql.NUMBER';I think i've got it from the forum but i don't remember from whom.
Bernd
Similar Messages
-
How to improve performence of the procedure using regular expressions
Hi all,
I have used substr, instr functions in this procedure .
Kindly tell me how use regular_expressions in this procedure .
/* Formatted on 2011/07/20 17:18 (Formatter Plus v4.8.8) */
PROCEDURE pr_insrt_prcdr_rvne_edit ( --ver 4.4
p_pa_rqst_sid IN NUMBER,
p_err_code OUT NUMBER,
p_err_msg OUT VARCHAR2
IS
v_count NUMBER;
CURSOR error_dtls
IS
SELECT parent_target_table_sid, inbnd_target_table_cid,
target_table_sid
FROM inbnd_278_error
WHERE parent_target_table_sid = p_pa_rqst_sid
AND SUBSTR (error_data_value, INSTR (error_data_value, ':') + 1) IN
('5056', '5031');
CURSOR error_values (
p_target_table_sid inbnd_278_error.target_table_sid%TYPE
IS
SELECT MAX (DECODE (SUBSTR (error_data_value,
INSTR (error_data_value, ':', 1) + 1
'5056', SUBSTR (error_data_value,
1,
INSTR (error_data_value, ':', 1) - 1
) AS e5056,
MAX (DECODE (SUBSTR (error_data_value,
INSTR (error_data_value, ':', 1) + 1
'5031', SUBSTR (error_data_value,
1,
INSTR (error_data_value, ':', 1) - 1
) AS e5031
FROM inbnd_278_error
WHERE target_table_sid = p_target_table_sid
AND SUBSTR (error_data_value, INSTR (error_data_value, ':', 1) + 1) IN
('5056', '5031');
v_error_values error_values%ROWTYPE;
BEGIN
p_err_code := 0;
p_err_msg := 'Success';
FOR curr_error_dtls_rec IN error_dtls
LOOP
OPEN error_values (curr_error_dtls_rec.target_table_sid);
FETCH error_values
INTO v_error_values;
IF (v_error_values.e5056 IS NOT NULL
AND v_error_values.e5031 IS NOT NULL
THEN
DELETE FROM inbnd_278_error
WHERE SUBSTR (error_data_value,
INSTR (error_data_value, ':') + 1
) IN ('5056', '5031')
AND target_table_sid = curr_error_dtls_rec.target_table_sid
AND inbnd_target_table_cid = 109;
INSERT INTO inbnd_278_error
(inbnd_278_error_sid,
parent_target_table_sid, inbnd_target_table_cid,
target_table_sid, meta_data_cid,
error_data_value,
created_by, created_date
VALUES (inbnd_278_error_seq.NEXTVAL,
curr_error_dtls_rec.parent_target_table_sid, 109,
curr_error_dtls_rec.target_table_sid, 161,
v_error_values.e5056
|| ','
|| v_error_values.e5031
|| ':'
|| '5059',
1, SYSDATE
END IF;
CLOSE error_values;
END LOOP;
EXCEPTION
WHEN OTHERS
THEN
p_err_code := SQLCODE;
p_err_msg :=
'Error occured in pr_insrt_prcdr_rvne_edit procedure '
|| SUBSTR (SQLERRM, 1, 100);
END pr_insrt_prcdr_rvne_edit;
Thanks,
P Prakash
Edited by: prakash on Jul 20, 2011 4:48 AMYes as explained in the forum FAQ which you should read
http://forums.oracle.com/forums/ann.jspa?annID=1535
*2. How do I ask a question on the forums?*
SQL and PL/SQL FAQ
And the section beginning.
*9) Formatting with {noformat}{noformat} Tags* -
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. -
Help in query using regular expression
HI,
I need a help to get the below output using regular expression query. Please help me.
SELECT REGEXP_SUBSTR ('PWRPKG(P/W+P/L+CC)', '[^+]+', 1, lvl) val, lvl
FROM DUAL,(SELECT LEVEL lvl FROM DUAL
CONNECT BY LEVEL <=(SELECT MAX ( LENGTH ('PWRPKG(P/W+P/L+CC)') - LENGTH (REPLACE ('PWRPKG(P/W+P/L+CC)','+',NULL))+ 1) FROM DUAL));
I need the output as
correct result:
==============
val lvl
P/W 1
P/L 2
CC 3
But i tried the above it is not coming the above result. Please help me where i did a mistake.
Thanks in advanceFrank gave you a solution in your other thread. You could simplify it if you are on 11g:
SQL> select * from table_x
2 /
TXT
TECHPKG(INTELLI CC+FRT SONAR)
PWRPKG(P/W+P/L+CC)
select txt,
regexp_substr(
txt,
'(.*\()*([^+)]+)',
1,
column_value,
null,
2
) element,
column_value element_number
from table_x,
table(
cast(
multiset(
select level
from dual
connect by level <= regexp_count(txt,'\+') + 1
as sys.OdciNumberList
order by rowid,
column_value
TXT ELEMENT ELEMENT_NUMBER
TECHPKG(INTELLI CC+FRT SONAR) INTELLI CC 1
TECHPKG(INTELLI CC+FRT SONAR) FRT SONAR 2
PWRPKG(P/W+P/L+CC) P/W 1
PWRPKG(P/W+P/L+CC) P/L 2
PWRPKG(P/W+P/L+CC) CC 3
SQL> SY. -
Rplacing space with &nbsb; in html using regular expressions
Hi
I want to replace space with &nbsb; in HTML.
I used the below method to replace space in my html file.
var spacePattern11:RegExp =/(\s)/g;
str= str.replace(spacePattern," "
Here str varaible contains below html file.In this html file i want to replace space present between " What number does this represents" with &nbsb;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B> What number does this Roman numeral represents MDCCCXVIII ?</B></FONT></P></TEXTFORMAT></b>
</body>
</html>
But by using the above regular expression i am getting like this.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P A LIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0 " KERNING="0"><B> What number does this represents</B></FONT></P></TEXTFORMAT></b>
</body>
</html>
Here what happening means it was replacing space with &nbsb; in HTML tags also.But want to replace space with &nbsb; present in the outside of the HTML tags.I want like this using regular expressions in FLEX
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>What number does this represents</body>
</html>
Hi,Please give me the solution to slove the above problem using regular expressions
Thanks in Advance to all
Regards
sssssssssorry i missed some information in above,The modified information was in red color
Hi
I want to replace space with &nbsb; in HTML.
I used the below method to replace space in my html file.
var spacePattern11:RegExp =/(\s)/g;
str= str.replace(spacePattern," "
Here str varaible contains below html file.In this html file i want to replace space present between " What number does this represents" with &nbsb;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B> What number does this Roman numeral represents MDCCCXVIII ?</B></FONT></P></TEXTFORMAT></b>
</body>
</html>
But by using the above regular expression i am getting like this.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head><body>
<b><TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B333C" LETTERSPACING="0" KERNING="0"><B></B></FONT></P></TEXTFORMAT><TEXTFORMAT LEADIN G="2"><P ALIGN="LEFT"><FONT FACE="Verdana" style = 'font-size:10px' COLOR="#0B33 3C" LETTERSPACING="0" KERNING="0"><B> What number does this represents</B></FONT></P></TEXTFORMAT></b>
</body>
</html>
Here what happening means it was replacing space with &nbsb; in HTML tags also.But want to replace space with &nbsb; present in the outside of the HTML tags.I want like this using regular expressions in FLEX
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>What&nbsb;number&nbsb;does&nbsb;this&nbsb;represents</body>
</html>
Hi,Please give me the solution to slove the above problem using regular expressions
Thanks in Advance to all
Regards
ssssssss -
Trying to use regular expressions to convert names to Title Case
I'm trying to change names to their proper case for most common names in North America (esp. the U.S.).
Some examples are in the comments of the included code below.
My problem is that *retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");* does not work as I expect. It seems that the toUpperCase method call does not actually do anything to the identified group.
Everything else works as I expect.
I'm hoping that I do not have to iterate through each character of the string, upshifting the characters that follow spaces.
Any help from you RegEx experts will be appreciated.
{code}
* Converts names in some random case into proper Name Case. This method does not have the
* extra processing that would be necessary to convert street addresses.
* This method does not add or remove punctuation.
* Examples:
* DAN MARINO --> Dan Marino
* old macdonald --> Old Macdonald <-- Can't capitalize the 'D" because of Ernst Mach
* ROY BLOUNT, JR. --> Roy Blount, Jr.
* CAROL mosely-BrAuN --> Carol Mosely-Braun
* Tom Jones --> Tom Jones
* ST.LOUIS --> St. Louis
* ST.LOUIS, MO --> St. Louis, Mo <-- Avoid City Names plus State Codes
* This is a work in progress that will need to be updated as new exceptions are found.
public static String toNameCase(String name) {
* Basic plan:
* 1. Strategically create double spaces in front of characters to be capitalized
* 2. Capitalize characters with preceding spaces
* 3. Remove double spaces.
// Make the string all lower case
String retName = name.trim().toLowerCase();
// Collapse strings of spaces to single spaces
retName = retName.replaceAll("[ ]+", " ");
// "mc" names
retName = retName.replaceAll("( mc)", " $1");
// Ensure there is one space after periods and commas
retName = retName.replaceAll("(\\.|,)([^ ])", "$1 $2");
// Add 2 spaces after periods, commas, hyphens and apostrophes
retName = retName.replaceAll("(\\.|,|-|')", "$1 ");
// Add a double space to the front of the string
retName = " " + retName;
// Upshift each character that is preceded by a space
// For some reason this doesn't work
retName = retName.replaceAll("( [^ ])([^ ]+)", "$1".toUpperCase() + "$2");
// Remove double spaces
retName = retName.replaceAll(" ", "");
return retName;
Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:56 AM
Edited by: FuzzyBunnyFeet on Jan 17, 2011 10:57 AMHopefully someone will still be able to provide a RegEx solution, but until that time here is a working method.
Also, if people have suggestions of other rules for letter capitalization in names, I am interested in those too.
* Converts names in some random case into proper Name Case. This method does not have the
* extra processing that would be necessary to convert street addresses.
* This method does not add or remove punctuation.
* Examples:
* CAROL mosely-BrAuN --> Carol Mosely-Braun
* carol o'connor --> Carol O'Connor
* DAN MARINO --> Dan Marino
* eD mCmAHON --> Ed McMahon
* joe amcode --> Joe Amcode <-- Embedded "mc"
* mr.t --> Mr. T <-- Inserted space
* OLD MACDONALD --> Old Macdonald <-- Can't capitalize the 'D" because of Ernst Mach
* old mac donald --> Old Mac Donald
* ROY BLOUNT,JR. --> Roy Blount, Jr.
* ST.LOUIS --> St. Louis
* ST.LOUIS,MO --> St. Louis, Mo <-- Avoid City Names plus State Codes
* Tom Jones --> Tom Jones
* This is a work in progress that will need to be updated as new exceptions are found.
public static String toNameCase(String name) {
* Basic plan:
* 1. Strategically create double spaces in front of characters to be capitalized
* 2. Capitalize characters with preceding spaces
* 3. Remove double spaces.
// Make the string all lower case
String workStr = name.trim().toLowerCase();
// Collapse strings of spaces to single spaces
workStr = workStr.replaceAll("[ ]+", " ");
// "mc" names
workStr = workStr.replaceAll("( mc)", " $1 ");
// Ensure there is one space after periods and commas
workStr = workStr.replaceAll("(\\.|,)([^ ])", "$1 $2");
// Add 2 spaces after periods, commas, hyphens and apostrophes
workStr = workStr.replaceAll("(\\.|,|-|')", "$1 ");
// Add a double space to the front of the string
workStr = " " + workStr;
// Upshift each character that is preceded by a space and remove double spaces
// Can't upshift using regular expressions and String methods
// workStr = workStr.replaceAll("( [^ ])([^ ]+)", "$1"toUpperCase() + "$2");
StringBuilder titleCase = new StringBuilder();
for (int i = 0; i < workStr.length(); i++) {
if (workStr.charAt(i) == ' ') {
if (workStr.charAt(i+1) == ' ') {
i += 2;
while (i < workStr.length() && workStr.charAt(i) == ' ') {
titleCase.append(workStr.charAt(i++));
if (i < workStr.length()) {
titleCase.append(workStr.substring(i, i+1).toUpperCase());
} else {
titleCase.append(workStr.charAt(i));
return titleCase.toString();
{code} -
Using regular expressions in java
Does anyone of you know a good source or a tutorial for using regular expressions in java.
I just want to look at some examples....
Thanksthanks a lot... i have one more query
Boundary matchers
^ The beginning of a line
$ The end of a line
\b A word boundary
\B A non-word boundary
\A The beginning of the input
\G The end of the previous match
\Z The end of the input but for the final terminator, if any
\z The end of the input
if i want to use the $ for comparing with string(text) then how can i use it.
Eg if it is $120 i got a hit
but if its other than that if should not hit. -
Using Regular Expressions in Numbers 09?
Is there any way to use regular expressions in Numbers 09 in Find & Replace?
kilowattradio wrote:
Is there any way to use regular expressions in Numbers 09 in Find & Replace?
NO !
_Go to "Provide Numbers Feedback" in the "Numbers" menu_, describe what you wish.
Then, cross your fingers, and wait _at least_ for iWork'10
Yvan KOENIG (VALLAURIS, France) vendredi 25 septembre 2009 14:49:49 -
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 -
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 -
How to define a regular expression using regular expressions
Hi,
I am looking for some regular expression pattern which will identify a regular expression.
Also, is it possible to know how does the compile method of Pattern class in java.util.regex package work when it is given a String containing a regex. ie. is there any mechanism to validate regular expression using regular expression pattern.
Regards,
AbhisekI am looking for some regular expression pattern which will identify a regular
expression. Also, is it possible to know how does the compile method of
Pattern class in java.util.regex package work when it is given a String
containing a regex. ie. is there any mechanism to validate regular
expression using regular expression pattern.It is impossble to recognize an (in)valid regular expression string using a
regular expression. Google for 'pumping lemma' for a formal proof.
kind regards,
Jos -
Using Regular Expressions To Remove Characters JDK 1.4
I want to write a regular expression to remove all commas in a string of text.
string is:
1,000
or 1,000,000
I want it to return 1000 and 1000000.
I have tried some but I am just starting with Regular Expressions.
Please Help!Try this tutorial: Linux : Education : Tutorials
Using regular expressions
David Mertz
President, Gnosis Software, Inc.
September 2000
http://www-105.ibm.com/developerworks/education.nsf/linux-onlinecourse-bytitle/6C2B4863702F592B8625696200589C5B?OpenDocument -
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.
-
Using regular expressions for validation in i18n
Can we use regular expressions for validation of inputs in a java application taking care of i18N aspects too. Zip code for different locales are different. Can we use regular expressions to validate zipcode inputs from different locales
hi,
For that shall i have to create individual patterns for matching the inputs from different locales or a single pattern will do in the case of validating phone nos. around the world, zip codes etc. In case different patterns are required, programmer should have a konwledge of difference in patters for different locales.
regards
sdas -
Using regular expressions to get a customized output
Hi,
I have a string/varchar variable with the data ',a,b,c,' in it.
I want the display as follows:
a
b
c
I would like to get the similar output using regular expressions.
How do I get this output using REGEXP_REPLACE or REGEXP_SUBSTR?
Please do the needful.
Thanks & Regards,
RakshitI remember that, however if we look closer, that one has a little flaw: The 2nd row should be null, because ",," indicates an empy field. The MODEL clause solution works just fine in this case:
with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)
-- end of sample data
SELECT col_new
FROM t
MODEL
PARTITION BY (ROWNUM rn)
DIMENSION BY (0 dim)
MEASURES(col1, col1 col_new)
RULES ITERATE(99) UNTIL (ITERATION_NUMBER = LENGTH(REGEXP_REPLACE(col1[0], '[^,]')))
(col_new[ITERATION_NUMBER] = REPLACE(REGEXP_SUBSTR(col1[0], '(^|,)[^,]*', 1, ITERATION_NUMBER+1), ','))
COL_NEW
aaaa
bbbb
cccc
dddd
eeee
ffff
7 Zeilen ausgewählt.Update: I had this nagging feeling that I missed something, and there it was. If you want to see what the problem with my solution is, change the example to
with t as (select ',aaaa,,bbbb,cccc,dddd,eeee,ffff' col1 from dual)So I went back and tried to fix BlueShadows approach. Here it is:
with t as (select 'aaaa,,bbbb,cccc,dddd,eeee,ffff' txt from dual)
-- end of sample data
SELECT REPLACE(REGEXP_SUBSTR(',' || txt, ',[^,]*', 1, level), ',') col_new
FROM t
CONNECT BY level <= length(regexp_replace(txt,'[^,]*'))+1
;C.
Maybe you are looking for
-
How to show all user logged in/loggout in Report
How to display All User Logged in time & Logout Time? Hi.. I want to display All user in Portlet a report that show us all user that logged in the portal, their username, their time logged in, their time logged out.. where can i find these informatio
-
Hi All, We have a requirement which shows Vendor payment details. Is there any standard report which will serve the following requirement. Vendor has sent an Invoice for Rs. 20000 There are goods rejection for Rs. 5000 The final check payment if
-
How to customize the section's content in left bar?
How to customize the section's content in left bar. I hope to change create job's content, recent job's content etc. Or it is impossible? regards ren
-
How to delete infoobject by transport request?
Hi experts, I want to delete infoobject from productive system by transport request without deleting this infoobject from development system. Is it possible? How can I do this? Thanks!
-
How to write data in differt line in .txt file
Hi all, I am tring to write data on one file using utl_file, the first cursor loop write data on first line of the file using utl_file.put_line(..........................); end the second cusor loop write the data on secion line of the same file usin