sql,regex,oracle,oracle11g,regexp-replace
This should not be difficult. If you have a country code column in your CONTACT table and a separate table COUNTRY_MAPPING, then such a query might look like this (FYI, Poland's prefix is 48 as you correctly have in your CONTACT table, not 22 as you have in your COUNTRY_MAPPING...
regex,postgresql,regexp-replace
This is relatively straightforward. Note that both the backslash character \ as well as the single-quote character ' (which you escaped in the OP) need to be escaped. The difference is that the backslash has to be escaped in the regex itself, whereas the single quote is escaped in the...
regex,string,oracle,regexp-replace
[:alphanum:] alphanum is incorrrect. The alphanumeric character class is [[:alnum:]]. You could use the following pattern in the REGEXP_REPLACE: ([[:alnum:]]{4})([[:space:]]{1})([[:digit:]]{3})([[:space:]]{1})([[:alpha:]]{3}) Using REGEXP SQL> SELECT REGEXP_REPLACE('R4SX 315 GFX', 2 '([[:alnum:]]{4})([[:space:]]{1})([[:digit:]]{3})([[:space:]]{1})([[:alpha:]]{3})', 3 '\1\2\3\5') 4 FROM DUAL; REGEXP_REPL ----------- R4SX 315GFX SQL> If you are not sure about the number of characters...
sql,oracle,replace,oracle10g,regexp-replace
You could use REGEXP_REPLACE. For example, SQL> WITH DATA(str) AS( 2 SELECT 'XXXOABBOABBBBOABBBOABBBOABBBOABBBOOABUXXX' FROM dual 3 ) 4 SELECT str, regexp_replace(str, '(.)\1+','\1') new_str FROM DATA; STR NEW_STR ----------------------------------------- ---------------------------- XXXOABBOABBBBOABBBOABBBOABBBOABBBOOABUXXX XOABOABOABOABOABOABOABUX SQL> ...
You have wrapped all the columns of your projection in unnecessary brackets. It compiles but the clutter is preventing you from seeing the problem. Without those brackets it becomes clear you have a column with two aliases: regexp_replace(passport_no,'D','B')"regexp_replace" as passport_no You posted a working query. It works because it has...
oracle,regexp-replace,regexp-substr
Selecting the first four words: select regexp_replace( 'Hello world this is a test etc', '(((\w+)\s){4}).*', -- Change 4 to wanted number of words here! '\1' ) from dual; Edit The above solution only works if the words are seperated by exactly one white space character. If the words are seperated...
I got the working query now. Please check this so that it can help others. INSERT INTO TMP_SOAP_MONITORING_IDS ("ID",SUBSCRIPTION_ID,ORDER_TYPE,ORDER_NUMBER) SELECT ID,xt_req.SUBSCRIPTION_ID,xt_res.ORDER_TYPE,xt_rrr.ORDER_NUMBER FROM TEMP_SOAP_MONITORING sm CROSS JOIN XMLTable(XMLNAMESPACES ( 'http://schemas.xmlsoap.org/soap/envelope/' AS "soapenv", 'http://service.soap.CDRator.com' as "ns", 'http://core.data.soap.CDRator.com/xsd' as "ax2130", 'http://webshop.result.service.soap.CDRator.com/xsd' as "ax2147" ), 'for $i in...
regex,tcl,regexp-replace,regexp-substr
You need to set the variables for the match and captured groups, then you can access them. Here is an example: set a "10.20.30.40" set rest [regexp {[0-9]+\.([0-9]+)\.([0-9]+)\.[0-9]+} $a match submatch1 submatch2] puts $submatch1 puts $submatch2 Output of the demo 20 30 EDIT: You can use regsub and backerferences this...
Try with the following query: select regexp_replace('IAmGoodBoy','([A-Z][^A-Z]*)','\1 ') from dual; ...
use regexp_replace(yourValue,'(XX)0([0-4])(*)', '\1\2\3') It will works for all the case you specified... It will only replace the 0 if it is followed by another number as it is in the case you have. If you have a 0 not followed by a number then it won't be replaced. Not sure...
You were almost there. select regexp_replace( 'Hello OBLIG: 451451, world OBLIG: 12123456789, Task OBLIG: 789456123, world ', '(OBLIG: )([[:digit:]]*)([[:digit:]]{4})', '\1\3' , 'g' ); Of course, this assumes you always have at least 4 digits in each number....
postgresql,regex-negation,regexp-replace
select regexp_replace($$cassine' de' pecche' e'$$, $$(\s[^dn]?|\w\w)e'$$, '\1è', 'gi') regexp_replace ---------------------- cassinè de' pecchè è (1 row) Explanation: (\s[^dn]?|\w\w)e' ^ ^ ^ | | followed by e' | or 2 word chars space optionally followed by d or n ...
Here you go brother, that was a fun one: SELECT regexp_replace(regexp_replace ('234234234.88, 24444.88, 54523234.78, and 1044.52 are numbers in this example.', '(([0-9]{3})\.)', ',\1'),'(([0-9]{3}),)',',\1') FROM dual ...
sql,sql-server,string,tsql,regexp-replace
Just make use of PATINDEX for searching, append to the result string part by part: CREATE FUNCTION [dbo].[fn_ReverseDigits] ( @Value nvarchar(max) ) RETURNS NVARCHAR(max) AS BEGIN IF @Value IS NULL RETURN NULL DECLARE @TextIndex int = PATINDEX('%[^0-9]%', @Value), @NumIndex int = PATINDEX('%[0-9]%', @Value), @ResultValue nvarchar(max) = '' WHILE LEN(@ResultValue) <...
I think the best way is to keep it simple: Use one regex to match all the [icons...]: \[icons\b[^\[\]]*\] and a second regex to be used iteratively on each of this regex' matches: (\w+)=(['"])((?:(?!\2).)*)\2 Note that the first and third group will contain your desired values, the second group contains...
Well first you need to be able to describe what you want to do to understand how to build the expression. For example, it appears to be: group the 1st 4 numbers, then the next 2 numbers, then the next 3 numbers then the next 4 numbers. If this is...