regexp-replace

How to use Regex to replace square brackets from date field in Google Data Studio?

北城余情 提交于 2020-07-09 06:54:45
问题 I am trying to remove square brackets around a date field in Google Data Studio so I can properly treat it as a proper date dimension. It looks like this: [2020-05-20 00:00:23] and I am using the RegEx of REGEXP_REPLACE(Date, "/[\[\]']+/g", "") and I want it to look like this for the output: 2020-05-20 00:00:23 It keeps giving me error results and will not work. I can not figure out what I am doing wrong here, I've used https://www.regextester.com/ to verify that it should work 回答1: Regarding

Oracle regex replace multiple occurrences of a string surrounded by commas

…衆ロ難τιáo~ 提交于 2020-06-15 18:54:50
问题 I am looking for a way to replace (remove / replace with '') a character string in a comma-separated list of values in a column in an Oracle SQL database. For example, suppose I have the following data: select ('SL,PK') as col1 from dual union all select ('PK,SL') as col1 from dual union all select ('SL,SL') as col1 from dual union all select ('SL') as col1 from dual union all select ('PK') as col1 from dual union all select ('PI,SL,PK') as col1 from dual union all select ('PI,SL,SL,PK') as

Oracle db: How to add spaces in specific positions in strings

萝らか妹 提交于 2020-05-23 10:22:43
问题 Suppose I have a string (varchar2) and I want to add a space wherever I have two consecutive a's. So for example: 'graanh' -> 'gra anh' . OK, this is trivial to do, either with replace or regexp_replace . But both choke on three or more consecutive a's. For example: SQL> select replace('aaaaa', 'aa', 'a a') from dual; REPLACE ------- a aa aa SQL> select regexp_replace('aaaaa', 'aa', 'a a') from dual; REGEXP_ ------- a aa aa This is because the search for the "next" occurrence of the match

Replace data in array based on regex

落爺英雄遲暮 提交于 2020-03-23 07:57:10
问题 I have the next array with data (which is dynamically generated). Now I want to do some Magic and tweak the array. array(1) { ["table"]=> array(3) { ["header"]=> array(4) { [0]=> array(1) { ["c"]=> string(4) "Naam" } [1]=> array(1) { ["c"]=> string(7) "Functie" } [2]=> array(1) { ["c"]=> string(13) "Nevenfuncties" } [3]=> array(1) { ["c"]=> string(34) " commissies" } } ["caption"]=> bool(false) ["body"]=> array(3) { [0]=> array(4) { [0]=> array(1) { ["c"]=> string(16) "*|class:orange|*" } [1]

Regex: Add space after a number when followed by letter

試著忘記壹切 提交于 2020-02-05 06:16:25
问题 Following a set of numbers I would like to add a space to the string. For instance, the following strings should add a space after a number: Before After "0ABCD TECHNOLOGIES SERVICES" "0 ABCD TECHNOLOGIES SERVICES" "ABCD0 TECHNOLOGIES SERVICES" "ABCD 0 TECHNOLOGIES SERVICES" "ABCD 0TECHNOLOGIES SERVICES" "ABCD 0 TECHNOLOGIES SERVICES" "ABCD TECHNOLOGIES0 SERVICES" "ABCD TECHNOLOGIES 0 SERVICES" "ABCD TECHNOLOGIES 0SERVICES" "ABCD TECHNOLOGIES 0 SERVICES" "ABCD TECHNOLOGIES SERVICES0" "ABCD

Distinct of CSV values using REGEXP_REPLACE in oracle

落花浮王杯 提交于 2020-01-17 03:25:52
问题 I have a table with data like below Column A Column B ------------------------- 1 POW 2 POW 1 POWPRO 1 PRO 2 PRO 1 PROUTL 1 TNEUTL 1 UTL 1 UTLTNE And I need output like below Output Column A Column B 1,2 POW,POWPRO,PRO,PROUTL,TNEUTL,UTL,UTLTNE I tried below query. But the output is different. select dbms_lob.substr( ltrim(REGEXP_REPLACE(REPLACE( REPLACE( XMLAGG( XMLELEMENT("A",COLUMN_A ) ORDER BY COLUMN_A).getClobVal(), '<A>',','), '</A>',' '),'([^,]+)(,\1)+', '\1'), dbms_lob.substr( ltrim

regex javascript with case insensitive flag 'i' and global wont work

别来无恙 提交于 2020-01-06 08:42:06
问题 I working on method to highlight the query text found in a string the idea is to add bold marker to each occurrence found. the problem is when i try to replace all occurrence of the query text with g and i flag it doesn't do it, it looks like it ignore the i flag . this is the function : highlight = function(text,q){ if (text.indexOf(q) != -1) { text = text.replace(new RegExp("\\b".concat(q, "\\b"), 'gi'), '<b>' + q + '</b>'); } else{ q = q.split(' '); q.forEach(function (item) { if (text

regex javascript with case insensitive flag 'i' and global wont work

冷暖自知 提交于 2020-01-06 08:41:27
问题 I working on method to highlight the query text found in a string the idea is to add bold marker to each occurrence found. the problem is when i try to replace all occurrence of the query text with g and i flag it doesn't do it, it looks like it ignore the i flag . this is the function : highlight = function(text,q){ if (text.indexOf(q) != -1) { text = text.replace(new RegExp("\\b".concat(q, "\\b"), 'gi'), '<b>' + q + '</b>'); } else{ q = q.split(' '); q.forEach(function (item) { if (text

Trouble with REGEXP_REPLACE in MySQL 8

Deadly 提交于 2020-01-04 09:11:54
问题 I recently upgraded to MySQL 8 so that I can use the new Regular Expression functions (https://dev.mysql.com/doc/refman/8.0/en/regexp.html) to clean up a lot of bad addresses. However, I'm running into trouble using REGEXP_REPLACE. I'm starting by running a SELECT query as an example (so I can see what's going on before I run an UPDATE query): SELECT address1_raw, CONVERT(REGEXP_REPLACE (address1_raw, '^[0-9]+ ', '') USING UTF8) as replaced, CONVERT(REGEXP_SUBSTR(address1_raw, '^[0-9]+ ')

Oracle extract json fields using regular expression with oracle regexp_substr

若如初见. 提交于 2019-12-25 18:23:52
问题 I'm using Oracle query with regular expression and oracle regexp_substr to extract json fields from JSON string. whene I try to get the value of code key it working well and its value, but whene i try to get the value of results key it return null. I'm using this query: select regexp_replace(regexp_substr('{"code":"001","message":"success","transactionId":437,"results":{"name":"osama"}}','"results":\s*("(\w| )*")', 1, level), '"results":\s*"((\w| )*)"', '\1', 1, 1) results from dual connect