regexp help
Hello
I need to extract deposited number. Can please help me this extract using regexp.
for ex:
at the bottom of the message, I need to extract the value 434234234235435345634345 using REGEXP
ORA-20102: cw_upload_queue_item_meta | ec3_unique_file_ref:434234234235435345634345 | ORA-00001: unique constraint (IBIS. CW_UPLOAD_QUEUE_ITEM_META_PK) violated
user575115 wrote:
Thx.It works in 11g, 10g too error throw
That's why you have to mention your db version 4-digit during the validation of the questions:
Select
LTRIM (regexp_substr ('ORA-20102: cw_upload_queue_item_meta | ec3_unique_file_ref:434234234235435345634345 |)) ORA-00001: unique constraint (IBIS. ((CW_UPLOAD_QUEUE_ITEM_META_PK) violated ',': [^ |] +', 1, 2),': ')
f
of the double
Tags: Database
Similar Questions
-
Hello
I'm new to regular expressions, and I was wondering if someone could help me. I have a field that contains data in this format
VOLUME_ISSUE
---------------------
"Vol. 81 iss. 4'
'94, number 9' flight '.
I worked that how to get the Volume returned, but my question is how to do the second group of digits representing the question.
SELECT
regexp_substr (volume_issue, "[0-9] +'"), volume
From table_1
Thanks in advanceHello!
You can use the "instances" of the REGEXP_SUBSTR parameter to return a specific occurrence of the regular expression you're looking for.
For example:
SQL> SELECT REGEXP_SUBSTR('Vol 94 Iss 9','[0-9]+',1,2) FROM DUAL; R - 9
This regular expression search 1 or several numbers starting at the first character in the string and continuing until there is the second occurrence.
HTH!
-
I would like to extract all the digits in a string delimited by a point, possibly using string.split(). My abilities in writing expressions good regulare is simply not there, any help would be much appreciated
String regexp = ""; String s="this should result in nothing. Nothing at all."; s.split(regexp); //result: {} s="50"; s.split(regexp); //result: {"50"} s="11.5000.25"; s.split(regexp); //result: {"11","5000","25"} s="50x"; s.split(regexp); //result: {} s="11.500x.25"; s.split(regexp); //result: {}
The best I can do is
String[] splitS = s.matches("(?:\\d+\\.)*\\d+")? s.split("\\."):new String[0];
-
can you please help me understand this regexp
Dear experts,
I got the code of the Web site only.
But I am not able to understand.
I know its very basic question and I need to us in the form of documentation.
Please help understand this code
with data_cell as ( select q'~[{"id":"1666","issueId":"ezsats:10000:1418145284747","sapId":"1101854","name":"INDIRA DEVU MD PC","createdBy":"Someone, Adam","dateAdded":"2014/12/09"}, {"id":"1667","issueId":"ezsats:10000:1418145284747","sapId":"1125031","name":"IL INDIRA DEVU MD PC","createdBy":"Someone, Adam","dateAdded":"2014/12/09"}]~' cell from dual ) select rtrim(regexp_replace(cell,'.*?"name":"([^"]*).*?}.','\1;'),';') from data_cell / () The subexpression (a.k.a. a submatch or group) and subexpressions may be nested to any depth. Parentheses (subexpresions) also capture the matched element into a variable that may be used as a backreference. (aka grouping or submatching) and their use as backreferences. The following is a set of iteration metacharacters (a.k.a. quantifiers) that can control the number of times the preceding character is found in our searches. The iteration meta characters can also be used in conjunction with parenthesis meta characters. . The . (period) means any character(s) in this position, for example, ton. will find tons, tone and tonneau but not wanton because it has no following character. ? The ? (question mark) matches when the preceding character occurs 0 or 1 times only, for example, colou?r will find both color (u is found 0 times) and colour (u is found 1 time). * The * (asterisk or star) matches when the preceding character occurs 0 or more times, for example, tre* will find tree (e is found 2 times) and tread (e is found 1 time) and trough (e is found 0 times). + The + (plus) matches when the preceding character occurs 1 or more times, for example, tre+ will find tree (e is found 2 times) and tread (e is found 1 time) but NOT trough (0 times).
Hello
Like John said, if you want to talk about the suggestion of someone, then it makes more sense to respond to this proposal in the same thread.
Try to split the term complicated part smaller, easier to understand, like this:
Select rtrim (regexp_replace (cell
, '.*?' || -any text (as low as possibble)
"« nom » : »" ||
'(' || -- \1 is ...
'[^"]*' || -0 or more characters, but without quotes
')' || -end \1
'.*?' || -any text (as low as possibble)
'}.' -a hug right, followed by any 1 character
, '\1;'
)
, ';'
)
of data_cell
;
This makes it more clear what you first do replaces
x 1 "name": "y' 'x 2}. with a little
There
where x 1 and x 2 can be anything, except that you do not want 'something' to include another instance of the model that you are replacing. That's why you should use
.*? instead of simply
.*
The '?' after ' *' makes No greedy, i.e. when there is a game of choice, as little as possible. (The default value for the regular expressions must be greedy, or match as much as possible.)
Note that this solution assumes there is exactly 1 "name" element in each set of braces. For example, if you have a string like:
"[{'name': 'A', 'name': 'B', 'name': 'C', 'name': 'D'}, {'foo': 'bar'}]' he returned.
' ONE; [{'foo': 'bar'}] "The solution more complicated that I posted in response on the original thread #3 returns
' ONE; B; D"
Note also that none of them not what you asked.
-
I am trying to run the query in oarcle apps and wanted to select lines, that meets the multiple org code separated by and my input value is 127 123, it will convert to ('127 ', ' 123') this regexp
Select * from ORG_ORGANIZATION_DEFINITIONS where organization_code IN (select ' ('| regexp_replace (regexp_replace (regexp_replace (: p_inv_org_code, '() + ',','), ',' "'," '),'^ | $', "') |')) (' double)
-NGO
Hello
This is the forum for the SQL Developer tool. Any questions about SQL or PL/SQL problems please post in SQL and PL/SQL
Concerning
Marcus
-
Hello
My version of Oracle: 11G
Here is a string I get in a flat file:
2009-01 - 01 T 14: 02:02.789
My requirement is to transform in 2009-01-01 14:02:02
(1) T must be replaced by a space
point 2) and the characters that follow must be replaced by null
PS: I realized using multiple functions, but you are looking to do this using a function only, I guess regexp_replace might help me thereby or is it does nothing else.
Concerning
Rahul
One more way!
regexp_replace ('2009 - 01-01 T 14: 02:02.789 ',' t |) () \. [[ : digit :]] * $) «, » ')
-
Good day experts,
How I would write this SQL using regexp:
Select *.
from all_source
where lower (text) like ' % insert into table % ' and owner = 'TEST ';
The problem is some programmers put the words 'insert', 'en' and 'table_name' in different lines and I can't get a match. Is it possible to catch them in the next row with regexp? or y at - it another way, I can see what database objects to insert into a table?
Best regards
Igor
Hello
Depending on how in-depth you want to be, use the PL/SQL.
If you must use SQL, can assume you that each of the words you are looking for ('insert', 'en' and 'table') will be on 1 line? If so, use LEAD and LAG to combine 3 lines, so you can test them all together, for example
REGEXP_LIKE (text |) ' '
|| LEAD (text 1) OVER (PARTITION BY owner, name, type)
ORDER online
)
|| ' '
|| LEAD (text 2) OVER (PARTITION BY owner, name, type)
ORDER online
)
'insert\s + into\s + table'
, 'i'
)
Beware of duplicates. For example, if line 43 contains the full text of target, then the above expression returns TRUE when the current row is 41, 42 or 43.
Comments and completely Interline will interfere. you will need to remove them.
PL/SQL will be easier to code and faster to execute.
-
Need help with instr/Regexp for the query
Hi people of Oracle
I use Oracle
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing options
I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.
According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).
Can we use REG_EXP
Help, please.
Thanks in advance.
Rajesh
with x as)
(
SELECT '+-+-POPPPPPP' STUDENT_RESPONSE, 1 numero_enregistrement FROM DUAL Union all the
SELECT ' + --AOPPPPPP++' STUDENT_RESPONSE, 2 numero_enregistrement FROM DUAL Union all the
SELECT "+-+-OPPPPPP -' STUDENT_RESPONSE, 3 numero_enregistrement FROM DUAL union all
SELECT '+-+-9OPPPPPP' STUDENT_RESPONSE, 4 numero_enregistrement FROM DUAL)
)
(SELECT NUMERO_ENREGISTREMENT,
TRIM (STUDENT_RESPONSE) X
WHERE
((INSTR (UPPER (TRIM (STUDENT_RESPONSE)),'-') = 0))
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), '+') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'O') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)), 'P') = 0)
OR (INSTR (UPPER (TRIM (STUDENT_RESPONSE)),' ')! = 0)
)
)Hi, Renon,
Rb2000rb65 wrote:
Hi people of OracleI use Oracle
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
With partitioning, OLAP, Data Mining and Real Application Testing optionsThanks for posting this (and the WITH clause for sample data). It is very useful.
I have a few responses from students and the valid values are + / / (alphabet) o/p and spaces at the end of the scam only not in the middle.
You combine several qeustions responses in a single VARCHAR2 column? It would be better to have a separate line for each question.
According to my condition, the registration number 2 3.4 must be in the request but I'm alone (chart 3).
What exactly are your needs? You try to find the rows where the student_response contains one of the forbidden characters, or if it contains a space anywhere, but at the end of the string?
Can we use REG_EXP
Yes, but it's pretty easy and probably more effective, do not use regular expressions in this case:
Here's one way:SELECT record_number , student_response FROM x WHERE TRANSLATE ( UPPER ( RTRIM (student_response, ' ')) , 'X+-OP' , 'X' ) IS NOT NULL ;
In other words, once you remove the spaces and all occurrences of '+', '-', 'o' or 'P', then the forbidden characters are left, and you want to select the line, if there is one of these.
If you really, really want to use a regular expression:
SELECT record_number , student_response FROM x WHERE REGEXP_LIKE ( RTRIM (student_response) , '[^-+OP]' -- or '[^+OP-]', but not '[^+-OP]'. Discuss amongst yourselves , 'i' ) ;
but, again, it will be probably slower than the first solution, using TRANSLATE.
Published by: Frank Kulash, October 17, 2011 13:05
Published by: Frank Kulash, October 17, 2011 13:41
What follows is a bit simpler that TRANSLATE:SELECT record_number , student_response FROM x WHERE RTRIM ( UPPER ( RTRIM (student_response, ' ')) , '+-OP' ) IS NOT NULL ;
-
Hi all
String:
< element > < spid > 050009O < / spid > < dsc > Senior Designer < / dsc > < Glu > < d > a </d: > < v > HR / < v > < / uom > < mid > < / mid > < mn > < / mn > < url > < / url > < lt > 0 < − > < ASC > < c > $ </c > < a > 0.01 < /a > < / ASC > < p > < c > USD/< c > < a > 0.01 < /a > < /p > < cc > < d > UNSPSC/< d: > < v > B43 / < v > < /cc > < pe > false < /pe > < exdt > < / exdt > < shn > designer < / shn > < lng > en_US < / LNG > < mu > < /mu > < afkt > < / eccn > < systemid sid > < d >/< d: > < v > 52215 < /v > < / sid > < sn > ENGINEERING SOLUTIONS INC. < g > < > 52215 ky | 050009O < /ky > < tn > system: CatalogItem < /tn > < / item >
The string above, I need to extract:
1. the value between < spid > & < spid > - i.e. 050009O
2. the value between the < p > < c > & </> c - i.e. USD
3. the value between </c > < a > and < /a > - i.e. 0.01
Note: segments < c > < / c > & < a > < /a > repeats in the string above, the values in the 2nd of the accident.
The long chain varies in length from one record to another and stored in the table as VARCHAR2 (4000 bytes]
If anyone has an idea on how to retrieve these values while reading the table PL/SQL and store under a table or a variable, which could help me to move forward.
Thank you very much in advance.You are looking for something like this?
with yourtable as ( select '
050009O Senior Designer UN HR 0 ' yourcolumn from dual ) select regexp_replace(yourcolumn,'.*USD 0.01(.*) .*','\1'), regexp_replace(yourcolumn,'.*(.*) .*','\1') from yourtable; -
Help - REGEXP: ignore zeros when it is followed by letters
Hello
I have a database with the data entered is wrong.
Ex: 1NC_P51234, 1NC_P01234, 1NC_P0001234
Is it possible to do a query: SELECT * from table where name like '% 1NC_P51234' and resulting:
1NC_P51234
1NC_P01234
1NC_P0001234
Basiccly YES, after the undercore and the letter P, ignoring the zero
Thanks in advance,
Roseline, Montreal, Quebec, Canada
Published by: Katie on October 26, 2009 08:14Hi, Roseline,.
I think I understand now. Examples of great help, and done the formatting.
Let's rewrite the existing query, to make it more clear what he does:
SELECT * FROM table_x WHERE REGEXP_LIKE ( name , '_P' || -- (a) the characters '_' and 'P', followed by '0*' || -- (b) 0 or more '0's , followed by '[1-9]' || -- (c) any of the characters '1' througn '9' ) ;
That may have worked perfectly for your orriginal problem, but now you have a slightly different problem.
Before the optional '0', now you can get the 5 string '06 M - P' nstead of the string 2 "_P". You can simply change the part (a).
After the '0' option, you must now find the character '2' instead of characters 'by 9' 1. You can simply change the part (c), and you now have:SELECT * FROM table_x WHERE REGEXP_LIKE ( name , '06M_P' || -- (a) the characters '0', '6', 'M', '_' and 'P', followed by '0*' || -- (b) 0 or more '0's, followed by '2' || -- (c) the character '2' ) ;
Again another time, condition (a) can be '09R_P' and condition (c) could be "600", in which case you could say:
SELECT * FROM table_x WHERE REGEXP_LIKE ( name , '09R_P' || -- (a) the characters '09R_P', followed by '0*' || -- (b) 0 or more '0's, followed by '600' || -- (c) the characters '600' ) ;
Actually, all of the queries above work exactly as written. The 2nd argument of REGEXP_LIKE can be any kind of expression.
It can be a single literal string, like'_P0*[1-9]'
or it can be a concatenation of string literals 3, as
'09R_P' || '0*' || '600'
or it can be a concatenation of literals and bind variables, as
:part_a || 'P_0*' || :part_c
or it can be a concatenation of any kinds of string expressions, including
literals,.
bind variables,
columns,
SUBSTR,
CASE expressions,
even other regular expressions. -
Hello world
I have a question
I, ve a regexp select statement looking for the age of the people
example of
Select regexp_substr(age,'\d+$')
of frs_uzk_vacations vce
where id = 20
You can try also is to choose the double
for example
Select regexp_substr('23','\d+$')
Double;
the result is: 23
But the problem is that when you select regexp_substr('23+','\d+$')
Double;
you get noting in return
and I want to have "23", regardless of the operator +. I want to exclude the ' + '.
Can someone advise me on this pleasse.
My respectsHere are two possible solutions. Use regexp_substr and and the other using regexp_replace:
with t1 as (select '1) age=23' age from dual union all select '2) string 24+' from dual ) select regexp_replace(age, '.*?' --Optionally match everything before the age ||'(\d+)' --Capture the age ||'[+]?' --Optionally match the trailing + ||'$' --Anchor to the end of the line , '\1' --Replace everything that was matched --with the first parenthasized expression ) age1 , rtrim(regexp_substr(age, '\d+'--Match the age ||'[+]?'--Optionally match the trailing + ||'$' --Anchor to the end of the line ), '+') --Trim any trailing + signs from t1;
-
Hello
I need to retrieve a string for the beginning to the LAST occurrence of "225xxx."
I guess that the SQL should look like:
Select regexp_substr ('225100-225800, 225900-225905, 225908, 999, 321000-321999, 225907', 225 [^,] +,', 1, XXXXX) of the double;
for
225100-225800, 225900-225905, 225908, 999, 321000-321999, 225907.
the expected output is
225100-225800, 225900-225905, 225908, 999, 321000-321999, 225907.
for
225100-225999, 100-999, 321000-321999
the expected output is
225100-225999,
for
225100-225800, 225900-225905, 225908, 999, 321000-321999
the expected output is
225100-225800, 225900-225905, 225908,
Thank youSomething like this:
SQL> ed Wrote file afiedt.buf 1 with t as (select '225100-225800,225900-225905,225908,999,321000-321999,225907,' col1 from dual 2 union all select '225100-225999,100-999,321000-321999' from dual 3 union all select '225100-225800,225900-225905,225908,999,321000-321999' 4 from dual) 5* SELECT REGEXP_SUBSTR(col1,'.*225\w+,') from t SQL> / REGEXP_SUBSTR(COL1,'.*225\W+,') ---------------------------------------------------------------------------------------------------- 225100-225800,225900-225905,225908,999,321000-321999,225907, 225100-225999, 225100-225800,225900-225905,225908, SQL>
-
Help me understand this Regexp
I have problem understand why when using alpha the * seems to be lazy and to return nothing since I ask zero or more, so that when I do the same thing with a figure, then it is greedy (as I expected) and returns the whole number, not only the first digit.SQL> select regexp_substr('1234 dill 123 dall','[[:alpha:]]') from dual; R - d SQL> select regexp_substr('1234 dill 123 dall','[[:alpha:]]*') from dual; R - SQL> select regexp_substr('1234 dill 123 dall','[[:digit:]]') from dual; R - 1 SQL> select regexp_substr('1234 dill 123 dall','[[:digit:]]*') from dual; REGE ---- 1234
Why is this?
Edited by: Marius2 11 May 2009 14:39Marius2 wrote:
SQL > select regexp_substr (1234' dill 123 dall ',' [[: alpha:]]') twice;R
-
dSQL > select regexp_substr (1234' dill 123 dall ',' [[: alpha:]] *') twice;
R
-SQL > select regexp_substr (1234' dill 123 dall ',' [[: digit:]]') twice;
R
-
1SQL > select regexp_substr (1234' dill 123 dall ',' [[: digit:]] *') twice;
REGE
----
1234I have problem understand why when using alpha the * seems to be lazy and to return nothing since I ask zero or more, so that when I do the same thing with a figure, then it is greedy (as I expected) and returns the whole number, not only the first digit.
Why is this?
Use + instead of *.
-
Need help with EEM applet 'info type snmp oid' and 'Add' the syntax of commands
I am trying sample and adding a number of OIDs in the mib/ISDN on 2431 & 2921 boxes. The number of T1s on the boxes can vary with the model and configuration of the box. I studied the OID I want to loop through and am sure those to whom I need to try, but I can't build the digital oid using the command 'Add' and get the SNMP get command use the result. Here is my test cmdlet:
config t
No test event manager applet
applet Test Event manager
event no
Info action 200 type snmp oid 1.3.6.1.2.1.10.20.1.3.1.0 get-exact type! isdnSignalingGetIndex
game action 202 j "$_info_snmp_value".
game action 203 I '1 '.
game action 204 k '2 '.
206 action value calls '0 '.
action 210 all $i lt $j! Browse the ISDN interfaces
action 215 all 4 $k! Browse calls in & stats connectes.2 &.4
game action 220 myoides "1.3.6.1.2.1.10.20.1.3.3.1."
action 222 Add $myoid ' $k$ I ".
Info action 223 type snmp oid get exact $myoid
action 224 puts "" myoides = $myoid, i = $i, j $j, k = $k, value = snmp oid = $_info_snmp_value ".
action 225 regexp ' [0-9] + "" $_info_snmp_value ".
the 226 if action $_regexp_result eq 1
227 Add $Calls action $_info_snmp_value
game action 228 $Calls "$_result '.
229 action puts 'calls is $Calls. "
230 action ended
action 232 increment k 2
end of the 234 action
action 240 increment i
250 action ended
end
clear all system event handler
test run the event handler
Here is the result when I run the cmdlet:
bctrunks-2431-2 #event man run test
myoides = 1.3.6.1.2.1.10.20.1.3.3.1, i = 1, j = 2, k = 2, 2 = snmp oid value
Calls = 0
myoides = 1.3.6.1.2.1.10.20.1.3.3.1, i = 1, j = 2, k = 4, 2 = snmp oid value
Calls = 0
Here's a snmpwalk on Solaris 10 of the poll server the OID I am trying sample and add
-bash-3, $00 snmpwalk-v1 - c TWC-default 10.40.209.2 1.3.6.1.2.1.10.20.1.3.1.0
SNMPv2 - SMI:transmission.20.1.3.1.0 = INTEGER: 2<---- this="" is="" isdnsignallinggetindex="" which="" is="" 1="" +="" last="" isdn="" port="">---->
-bash-3, $00 snmpwalk-v1 - c TWC-default 10.40.209.2 1.3.6.1.2.1.10.20.1.3.3.1
SNMPv2-SMI::transmission.20.1.3.3.1.1.1 = Counter32 : 10
SNMPv2-SMI::transmission.20.1.3.3.1.2.1 = Counter32 : 10<----- this="" is="" the="" number="" of="" isdn="" outbound="" calls="">----->
SNMPv2-SMI::transmission.20.1.3.3.1.3.1 = Counter32 : 2
SNMPv2-SMI::transmission.20.1.3.3.1.4.1 = Counter32 : 2<------ this="" is="" the="" number="" of="" isdn="" inbound="" calls="">------>
SNMPv2-SMI::transmission.20.1.3.3.1.5.1 = Counter32 : 0
-bash-3, $ 00
In this case, the cmdlet must obtain the OID 1.3.6.1.2.1.10.20.1.3.3.1.2.1 & 1.3.6.1.2.1.10.20.1.3.3.1.4.1 values and add them.
The comand 'append' does not seem to be working properly, as indicated by the value of myoides. The IOS command result search tool for the "add action".
order does not explicitly say where the result of append it is placed, so I guess that the result is placed in the variable 'myoides' in my test applet.
I have successfully used the 'action info exact snmp oid
get-type type' syntax in the past, but I do not know if it works using a constructed string variable. Let me know if you can help me. Thanks in advance.
Add use the variable name not its value. Try this instead:
action 222 Add myoides ' k $I ".
-
Customized using regexp check constraint
Oracle 11.2.0.1
I need a customized using regexp expressions check constraint. We have a single column in our table REGNO, which is used to keep the registration number of our customers. It has alpha and numeric values, the first is Alpha and rest is digital with preceding zeros as A0100 A1245, C1111 etc. Sometimes, in the application user enters regnos evil if we want to stop entering the bad regnos i.e. assume that the user name is Ashok Kumar and in the series, we have 1000 users so this new user should have A1001 (other than any value A1001, in this example, the constraint must be limit to enter the value) only, not the others nor a1001 , A1000, nor A1002 or < has no > 1001 too. Rather than having 26 sequences (A to Z), we get a table where we have these columns:
Alpha char (1), number of LastNo. But sometimes a user enters wrong number value and stores it in the table, so next time for the same gap alpha arrives and confusing.
So, we must have a constraint of database level so that ONLY the correct values must be entered.
Kindly help me how I have this task please.
Thank you.
If REGNO is a derived value then why let you the user enter a value. Just generate the user.
Maybe you are looking for
-
Well I have notbook comaq mini 700 and the hard drive is manufactured by Toshiba model num MK8028GAL (60 GB), the thing is this hard to read error as such when recently formatted the entire hard drive using windows and when I started to install windo
-
Ideas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem Remember - this is a public forum so never post private information such as numbers of mail or telephone!
-
I was informed by an outside vendor they need me to install a VPN site-to site on our ASA 5510/8, 4. I have configured the VPN IPsec site to site, but they have a weird requirement. For some reason, they want me NAT the server in question for 172.19.
-
I can open projects of aacs3 in aacs6?
I have a gran problema...! no open adobe audition cs3 en el cs6 proyectos los puedo... !! ¿Hay alguna respond available. ?
-
I just bought Adobe audition on creative cloud, and it does not work. Said that the trial period is over