Regular Expression Trouble
Hello All, Happy Holidays.
I'm creating a component in an application that is similar to
Facebook's "News Feed" feature. This feature lists rows from a
database which may contain some 'special text' that needs to be
converted to HTML. Note: I am storing the 'special text' in the
database instead of the actual html code to save space in the
database in case the name of the object is very long.
Here's what I'm trying to do:
In the database a record might look like this:
On 12/25/06 [user:253]John Smith[/a] Logged On.
When I display the table I want to convert it to the
following:
On 12/25/06 <a href="user_info.cfm?userId=253">John
Smith</a> Logged On.
I've been able to create the following regular expression
which does a good job converting the text to a link, but I am
unable to get the uniqueID (253) from the string. Note: Description
is the name of the column that is being processed.
<CFSET temp = ReReplace(Description,'\[User:.\]','<a
href="user_info.cfm?userID=253">','ALL')>
<CFSET temp =
ReReplace(temp,'\[/a\]','</a>','ALL')>
Is there a way I can convert the string in one regular
expression? Also, how can I get the number value after the colon
(:) and insert it into the replacement string?
Also, to complicate things, the string may have multiple
instances of 'special text'. For example:
On 12/25/06 [user:253]John Smith[/a] modified
[user:262]Captain Picard's[/a] account
Thanks for your help!
If I read your requirement correctly, you should replace
this:
\[user:([^\]]*)](.*)?\[/a]
With this:
<a href="user_info.cfm?userId=\1">\2</a>
The bit you were missing from your regex was capturing the
subexpressions
for the ID and the name. Can I suggest you read this:
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000990.htm,
and have
a bit of an experiment.
Also, Regex Coach is good for testing stuff:
http://weitz.de/regex-coach/
Adam
Similar Messages
-
Trouble with tribbles, i mean regular expressions
Hi all
im trying to make a regular expression that finds all the comments in a given string
stuff like this
/* this is my comment */
then what i want to do is to remove all those found comments from the string and leave me with the original string without any comments.
anyway i know i need a pattern but i cant get my pattern right, this is what i have at the moment
Pattern remComment = Pattern.compile(" ^\\*?[\\w\\s\\W]+?*\\ ", Pattern.DOTALL | Pattern.MULTILINE);
can anyone help me and let me know where im going wrong
im basically trying to say any thing that starts with \* <any other text here> until a *\
thanksThere is something else wrong, I just tryied:
* Comments.java
* version 1.0
* 07/06/2005
package samples;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
* @author notivago
public class Comments {
* @param args
public static void main(String[] args) {
String comment =
"/*\r\n" +
"does this do it won\r\n" +
"*/\r\n" +
".activegrouptab\r\n" +
"{\r\n" +
"white-space:nowrap;\r\n" +
"border-top-width:1pt;\r\n" +
"cursor:hand;\r\n" +
"}\r\n" +
"/*\r\n" +
"does this do it too\r\n" +
"*/\r\n" +
".activegrouptabdisabled\r\n" +
"{\r\n" +
"font-family:verdana;\r\n" +
"font-size:7pt;\r\n" +
"}\r\n" +
"/*\r\n" +
"does this do it free\r\n" +
"*/\r\n" +
".activesectiontab\r\n" +
"{\r\n" +
"width:90%;\r\n" +
"background-image:url(hocbt.gif);\r\n" +
"overflow:auto;\r\n" +
"color:#ffffff;\r\n" +
Pattern remComment = Pattern.compile("/\\*.*?\\*/", Pattern.DOTALL | Pattern.MULTILINE);
Matcher matcher = remComment.matcher(comment);
while( matcher.find() ) {
System.out.println( "The comment: \n" + matcher.group() );
System.out.println("----");
}with the output:
The comment:
does this do it won
The comment:
does this do it too
The comment:
does this do it free
---- -
Troubles with regular expressions
I seem to be having problems writing my regular expression. I check it on a regex testing website and it should work. Maybe I am doing something wrong because it is in Java and not Perl? I was wondering if someone could give me a little help?
Pattern p = Pattern.compile("<.*posttitle.*h2>", Pattern.DOTALL);
Matcher m = p.matcher(content);
boolean b = m.matches();That's what my regular expression looks like but the boolean b keeps returning false. The text I am looking at is the source code of [dailypoetryclub.com|http://dailypoetryclub.com] and I want to basically pull out just the links of each day's topic. Any ideas what I'm doing wrong?1) Sounds like you need find() not matches() (matches look for the whole string to match exactly) if you are looking for the pattern in a long string.
2) You should make the ".*" reluctant or it will take more than you expect. -
Help needed regarding regular expressions
hello
i need to write a program that recieves a matematical expression and evaluates
it...in other words a calculator :)
i know i need to use regular expressions inorder to determine if the input is legal or not ,but i'm really having trouble setting the pattern
the expression can be in the form : Axxze2223+log(5)+(2*3)*(5+4)
where Axxze2223 is a variable(i.e a combination of letters and numbers.)
where as: l o g (5) or log() or Axxx33aaaa or () are illegal
i tried to set the pattern but i got exceptions or it just didnt work the way i wanted it .
here's what i tried to do at least for the varibale form:
"\\s*(*([a-zA-Z]+\\d)+)*\\s*";
i'm really new to this...and i can't seem to set the pattern by using regular expressions,how can i combine all the rules to one string?
any help or references would be appreciated
thanksso i'll explain
let's say i got token "abc22c"(let's call it "token")
i wan't to check if it's legal
i define:
String varPattern = "\\s*[a-zA-Z]+\\d+\\s*";If you want to check a sequence of ASCII characters, longer than one, followed by a single digit, the whole possibly surrounded by spaces -- yes.
>
now i want to check if it's o.k
so i check:
token.matches(varPattern);
am i correct?Quite. It's better to compile the Pattern (Pattern.compile(String)), create a java.util.regex.Matcher (Pattern#matcher(CharSequence)), and test the Matcher for Matcher#matches().
(Class.method -> static method, Class#method -> instance method)
>
now i'm having problem defining pattern for log()
sin() cos()
that brackets are mandatory ,and there must be an
expression inside
how do i do that?First, I'd check the overall function syntax (a valid name, brackets), then whether what's inside the brackets is a valid expression (maybe empty), then whether that expression is valid for that function (presumably always?).
I might add I'm no expert on parsing, so that's more a supposition than a guide. -
Regular Expression Search for Case Statement in VBA
Hi,
I'm having trouble trying to use regular expressions in a case statement. I have a CSV spreadsheet of a server's netstat output and am trying to plot everything into Visio. I have been able to do that, however I'm not trying to expand this capability and
resuse the same code for many different servers.
I have the mainServer variable set as a Variant and in my current example it is set as "INTPXY001" (internal proxy server 001). I have tried different regex statements for the potential to have INTPXY001 - INTPXY999, EXTPXY001 - EXTPXY999, and
SVCPXY001 - SVCPXY999 in place of the Case "INTPXY001", but nothing I have tried seems to work.
'========================================
Set mainServer As Variant
Set AppVisio = CreateObject("visio.application")
AppVisio.Visible = True
AppVisio.Documents.AddEx "", visMSDefault, 0
AppVisio.Documents.OpenEx "server_u.vss", visOpenRO + visOpenDocked
mainServer = ActiveSheet.Cells(1, 2) 'sets mainServer to INTPXY001
With AppVisio.ActiveWindow.Page
Select Case mainServer
Case "INTPXY001"
.Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.ItemU("Proxy server"), 2.25, 9.25
Case Else
.Drop AppVisio.Documents.Item("SERVER_U.VSS").Masters.Item(("Server"), 2.25, 9.25
End Select
End With
'========================================You cannot declare variables As Variant in VBScript. All variables in VBScript are implicitly variants.
If you are asking about VBA (Visual Basic for Applications), then you're not asking in the correct forum.
-- Bill Stewart [Bill_Stewart] -
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 expressions with multi character separator
I have data like the
where |`| is the separator for distinguishing two fields of data. I am having trouble writing a regular expression to display the data correctly.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> declare
2 l_string varchar2 (200) :='123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes';
3 v varchar2(40);
4 begin
5 v:=regexp_substr(l_string, '[^(|`|)]+', 1, 1);
6 dbms_output.put_line(v);
7 v:=regexp_substr(l_string, '[^(|`|)]+', 1, 2);
8 dbms_output.put_line(v);
9 v:=regexp_substr(l_string, '[^(|`|)]+', 1, 3);
10 dbms_output.put_line(v);
11 v:=regexp_substr(l_string, '[^(|`|)]+', 1, 4);
12 dbms_output.put_line(v);
13 v:=regexp_substr(l_string, '[^(|`|)]+', 1, 5);
14 dbms_output.put_line(v);
15 end;
16 /
123
456
789 10 here
223
5434I need it to display
123` 456
789 10 here
|223
5434|`}22
yesI am not sure how to handle multi character separators in data using reg expressions
Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:35 PM
Edited by: Clearance 6`- 8`` on Apr 1, 2011 3:37 PMHi,
Actually, using non-greedy matching, you can do what you want with regular expressions:
VARIABLE l_string VARCHAR2 (100)
EXEC :l_string := '123` 456 |`|789 10 here|`||223|`|5434|`}22|`|yes'
SELECT LEVEL
, REPLACE ( REGEXP_SUBSTR ( '|`|' || REPLACE ( :l_string
, '|`|'
, '|`||`|'
) || '|`|'
, '\|`\|.*?\|`\|'
, 1
, LEVEL
, '|`|'
) AS ITEM
FROM dual
CONNECT BY LEVEL <= 7
;Output:
LEVEL ITEM
1 123` 456
2 789 10 here
3 |223
4 5434|`}22
5 yes
6
7Here's how it works:
The pattern
~.*?~is non-greedy ; it matches the smallest possible string that begins and ends with a '~'. So
REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 1) returns '~SHALL~'. However,
REGEXP_SUBSTR ('~SHALL~I~COMPARE~THEE~', '~.*?~', 1, 2) returns '~COMPARE~'. Why not '~I~'? Because the '~' between 'SHALL' and 'I' was part of the 1st pattern, so it can't be part of the 2nd pattern. So the first thing we have to do is double the delimiters; that's what the inner REPLACE does. The we add delimiters to the beginning and end of the list. Once we've done prepared the string like that, we can use the non-greedy REGEXP_SUBSTR to bring back the delimited items, with a delimiter at either end. We don't want those delimiters, so the outer REPLACE removes them.
I'm not sure this is any better than Sri's solution. -
Hi,
I have trouble in regular expressions.. I am trying to do something like this:
SELECT PRT_DESC FROM tablename
WHERE SUBSTR(PRT_DESC,5,5) LIKE '[0-9][0-9][0-9][0-9][0-9]'
Returns 0 rows which is incorrect..
Can anyone help me out??
ThanksOracle didn't support regular expressions until 10g. In prior versions, there is an owa_pattern package that may be useful to you here.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Juniper MX Regular expressions and user permissions ACS 5.4
Hi everyone!
Im having some trouble with regular expressions and permissions on our Juniper MX routers through ACS 5.4, and i would like some insight/help/poitners!!
We have a team of engineers that should only have read only permissions (important: show configuration) and also be able to just change the description on interfaces.
Thus far with the following regular expressions set for the shell profile they are going through i have managed the above, however the problem is when an engineer inputs "Show configuration", only the interfaces descriptions configuration is shown! The rest of the configuration will not be printed.
deny-commands1=.*.
allow-commands1=configure
deny-configuration1=.*.
allow-commands2=interfaces .*. description .*$
allow-configuration1=interfaces .*. description .*$
allow-commands2=show configuration.*
allow-commands3=show configuration
(some of these regex i know that are not needed, i was just playing around to check everything before posting)
Any pointers as to why or how to resolve this?
example output with the above:
show configuration
## Last commit: 2014-01-09 09:34:44 EET by someone
interfaces {
xe-0/0/0 {
xe-0/0/1 {
description xxxx;
xe-0/1/0 {
description xxxx;
xe-0/1/1 {
description xxxx;
xe-0/2/0 {
disable;
xe-0/2/1 {
description xxxx;
xe-0/3/0 {
description xxxx;
xe-0/3/1 {
description xxxx;
ae0 {
description "xxxx";
ae1 {
description xxxx;
demux0 {
lo0 {
{master}
Thanks in advance!
SpyrosYou are absolutely right!! I was doing research online after posting the above. The correct RADIUS attribute to use is actually CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools. Then create the pool in ASA, and call that pool's name in ACS under that RADIUS attribute. Someone explained this perfectly in this community before. Much appreciate your answer!
Here's from another post last year:
ACS 5 does not have the feature of IP pools. Logically its always good to setup pools locally on vpn server and if you want user to pick ip from specific local pool you can configure acs to push that attribute.
On ACS Go to > Policy Elements -> Network Access -> Authorization Profiles -> Create ->
Name of the Policy ->Dictionary Type: Radius-Cisco VPN 3000/ASA/PIX7.x
Attribute Type : CVPN3000/ASA/PIX7.x-Group-Based-Address-Pools
Attribute Type: String
Attribute Value : Static MYPOOL (Name of the Pool which is defined on the ASA)
Access Policies ->Default Network Access -> Authorization -> Create -> Under result section call the Authorization p -
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 -
Range & Regular Expression issue.
I'm having a bit of trouble and I'm close to head butting a wall. It's a logic problem. I am trying to create a class, when given a range e.g., 52 - 234 it will output the regular expression
[5][2-9] | [6-9][0-9] | [1][0-9][0-9] | [2][0-2][0-9] | [2][3][0-4]
another example
12-23
[1][2-9] | [2][0-3]
It's giving me a logic headache. I can't help but walk around thinking in for loops after trying to get this to work. However, I noticed that someone on the Internet has made a Java tool that does exactly this, but all their links are dead :o(
Anyone got any ideas? Seen this before? Done this yourself? Help? I've been at this for days now, and I'm fed up!
Thanks :o)Two things:
1. To use quote inside quoted string you must put two quotes in a row.
2. Certain characters have special meaning in regeular expressions. You must escape them with \ if you do not want regexp to interpret such characters.
Select regexp_replace('kathu&+','[/.#''& "\\-\+]')from dual;
REGEX
kathu
SQL>
{code}
SY. -
I haven't used regular expressions before, and I'm having trouble finding a regular expression to extract a string subset between two markers.
The string;
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
Header stuff I don't want
ERRORS 6
Info I want line 1
Info I want line 2
Info I want line 3
Info I want line 4
Info I want line 5
Info I want line 6
END_ERRORS
From the string above (this is read from a text file) I'm trying to extract the string subset between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number 1 through 32, and the number of lines I want to extract will correspond with this number. I can supply this number from a calling VI if necessary.
My current solution, which works but is not very elegant;
(1) uses Match Regular Expression to the return the string after matching ERRORS 6
(2) uses Match Regular Expression returning all characters before match END_ERRORS of the string returned by (1)
Is there a way this can be accomplished using 1 Match Regular Expression? If so could anyone suggest how, together with an explanation of how the regular expression given works.
Many thanks
Alan
Solved!
Go to Solution.I used a character class to catch any word or whitespace characters. Putting this inside parentheses makes a submatch that you can get by expanding the Match Regular Expression node. The \d finds digits and the two *s repeat the previous term. So, \d* will find the '6', as well as '123456'.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
CFFORM (Flash) Validation with Regular Expressions Not Working
I am having troubles getting regular expression validation to
work in a CFFORM. The below code is an extract of a much larger
form, the first name and last name have a regular expression
validation...and it doesn't work!
I'd appreciate any comments/info for help on this, have
searched high and low on information to get this working...but no
joy.
The code is:
<cffunction name="checkFieldSet" output="false"
returnType="string">
<cfargument name="fields" type="string" required="true"
hint="Fields to search">
<cfargument name="form" type="string" required="true"
hint="Name of the form">
<cfargument name="ascode" type="string" required="true"
hint="Code to fire if all is good.">
<cfset var vcode = "">
<cfset var f = "">
<cfsavecontent variable="vcode">
var ok = true;
var msg = "";
<cfloop index="f" list="#arguments.fields#">
<cfoutput>
if(!mx.validators.Validator.isValid(this,
'#arguments.form#.#f#')) { msg = msg + #f#.errorString + '\n';
ok=false; }
</cfoutput>
</cfloop>
</cfsavecontent>
<cfset vcode = vcode & "if(!ok)
mx.controls.Alert.show(msg,'Validation Error'); ">
<cfset vcode = vcode & "if(ok) #ascode#">
<cfset vcode =
replaceList(vcode,"#chr(10)#,#chr(13)#,#chr(9)#",",,")>
<cfreturn vcode>
</cffunction>
<cfform name="new_form" format="flash" width="600"
height="600" skin="halosilver" action="new_data.cfc">
<cfformgroup type="panel" label="New Form"
style="background-color:##CCCCCC;">
<cfformgroup type="tabnavigator" id="tabs">
<cfformgroup type="page" label="Step 1">
<cfformgroup type="hbox">
<cfformgroup type="panel" label="Requestor Information"
style="headerHeight: 13;">
<cfformgroup type="vbox">
<cfinput type="text" name="reqName" width="300"
label="First Name:" validate="regular_expression" pattern="[^0-9]"
validateat="onblur" required="yes" message="You must supply your
First Name.">
<cfinput type="text" name="reqLname" width="300"
label="Last Name:" validate="regular_expression" pattern="[^0-9]"
validateat="onblur" required="yes" message="You must supply your
Last Name.">
<cfinput type="text" name="reqEmail" width="300"
label="Email:" validate="email" required="yes" message="You must
supply your email or the address given is in the wrong format.">
<cfinput type="text" name="reqPhone" width="300"
label="Phone Extension:" validate="integer" required="yes"
maxlength="4" message="You must supply your phone number.">
</cfformgroup>
</cfformgroup>
</cfformgroup>
<cfformgroup type="horizontal"
style="horizontalAlign:'right';">
<cfinput type="button" width="100" name="cnt_step2"
label="next" value="Next"
onClick="#checkFieldSet("reqName,reqLname,reqEmail,reqPhone","new_form","tabs.selectedInd ex=tabs.selectedIndex+1")#"
align="right">
</cfformgroup>
</cfformgroup>
</cfformgroup>
</cfformgroup>
</cfform>quote:
Originally posted by:
Luckbox72
The problem is not the Regex. I have tested 3 or 4 different
versions that all work on the many different test sites. The
problem is it that the validation does not seem to work. I have
changed the patter to only allow NA and I can still type anything
into the text box. Is there some issue with useing Regex as your
validation?
Bear in mind that by default validation does not occur until
the user attempts to submit the form. If you are trying to control
the characters that the user can enter into the textbox, as opposed
to validating what they have entered, you will need to provide your
own javascript validation. -
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. -
Regular expression (regex) help!
I am trying to write a correct regular expression but am having difficulties.
I have a webpage saved as a string and want to extract all the links (urls) from the webpage string.
The trouble I am having is that some websites surround links using double quotes " " and some use single quotes ' ' around links in html:
Double quotes around url:
<a href="www.example.com"></a>
And single quotes:
<a href="www.example.com"></a>
So far I have a regex which extract links if they are surrounded with double quotes (see below), however if a page uses single quotes it screws up ;)
Pattern.compile("<a\\s+href\\s*=\\s*\"?(.*?)[\"|>]", Pattern.CASE_INSENSITIVE);So is there a way to say look for double quotes OR single quotes?
Many thanks
nullThere's no need to escape the single-quote (or apostrophe) in a regex. The only reason it was necessary to escape the double-quote (or quotation mark) is because the regex was written in the form of a String literal. Neither the single-quote or the double-quote has any special meaning in regexes.
Maybe you are looking for
-
My new computer is 64-bit running Windows 7 pro, SP1 and Microsoft Office 2010 Pro Plus 32-bit My phone is a 4S runing iOS 6.1.3 Very frustrated now that I have recently installed itunes and outlook on this new computer. Everything worked perfectly
-
Garageband doesn't OPEN??
I just got my mac book; brand new. and whenever I click the garageband icon, it just bounces once, and doesn't open or do anything after that. I've tried opening it different ways, through the Finder and right clicking, etc. What's wrong with it? Tha
-
MDM ABAP API ISSUE ( server is getting down )
Hi Folks, I am trying to retrieve matching results using MDM ABAP API. I am spiting source and target records into lot of blocks dynamically in program. I am getting output 2 to 3 times if i can run program sequential after that server is getting dow
-
Tuxedo running on AS400 or running applications of AS400 on Tuxedo .
Hi, Please share how and what is beneficial for the customer using AS/400. 1. To run the existing AS400 applications on Oracle tuxedo running in AS400 OR 2. To run applications of AS/400 on Oracle Tuxedo on different platforms like intel x64. Any ref
-
Pm_tick delay of .. ms exceeds .. ms
I have got sun cluster 3.2 in x86 in my PC I have got a numerous messages type "pm_tick delay of .. ms exceeds .. ms" what's matter? thanks