Getting examples from similar threads, Delete all characters after a specific character in PL / SQL as well as How to select a substring in Oracle SQL before a specific character?
I would like to get only the first characters before the appearance of the string.
Example:
STRING_EXAMPLE TREE_OF_APPLES
The resulting dataset should only show STRING_EXAMand TREE_OF_AP, because PLE- my separator
STRING_EXAM
TREE_OF_AP
PLE
Whenever I use below REGEXP_SUBSTR, it gets only STRING_because it is REGEXP_SUBSTRtreated PLEas separate expressions (P, L and E), and not as a single expression (PLE).
REGEXP_SUBSTR
STRING_
(P, L and E)
(PLE)
SELECT REGEXP_SUBSTR('STRING_EXAMPLE','[^PLE]+',1,1) from dual;
How can I do this without using numerous INSTR and SUBSTR?
Thank.
, [^PLE], , P L E. PLE . ,
[^PLE]
select REGEXP_SUBSTR(colname,'(.+)PLE',1,1,null,1) from tablename
PLE .
PLE ,
select REGEXP_SUBSTR(colname,'(.+?)PLE',1,1,null,1) from tablename
?
select substr(colname, 1, instr(colname, 'PLE')-1) from...
.
with inputs( colname ) as ( select 'FIRST_EXAMPLE' from dual union all select 'IMPLEMENTATION' from dual union all select 'PARIS' from dual union all select 'PLEONASM' from dual ) select colname, substr(colname, 1, instr(colname, 'PLE')-1) as result from inputs ; COLNAME RESULT -------------- ---------- FIRST_EXAMPLE FIRST_EXAM IMPLEMENTATION IM PARIS PLEONASM
Source: https://habr.com/ru/post/1663804/More articles:Understanding Object.clone () in Java - javaUnable to focus on typing after using angular -ui-bootstrap. - angular-ui-bootstrapПроизводительность и читаемость REGEXP_SUBSTR vs INSTR и SUBSTR - sqlIs it possible to correctly point to the Python library Shapely LIBGEOS_C in AWS Lambda? - pythonHow to blur an existing image in UIImageView using Swift? - iosWhat is the difference between deviceToken of type Data and token Fir InstanceID of type optional string in Swift - IOS? - iosВ этом асинхронном методе отсутствуют операторы "ждут" и будут выполняться синхронно - c#Ограничение размера точки входа в систему Webpack bundle.js - angulardestruct object in javascript es6 when keys are integer - javascriptНастройка Shapely для функций AWS Lambda Python - pythonAll Articles