Home » SQL & PL/SQL » SQL & PL/SQL » Regex Help
Regex Help [message #683397] Thu, 07 January 2021 12:25 Go to next message
ssmith001
Messages: 37
Registered: August 2018
Member
I've very new to writing regex and am struggling to write an expression to remove the text from the beginning, up to the name of the title.

[LZ3oXoFsOJo] Title A
[hGYM1XZrKyg] Tile B
[5SYJN0W] Tile C

All I want to return is
Title A
Title B
Title C
Re: Regex Help [message #683398 is a reply to message #683397] Thu, 07 January 2021 12:30 Go to previous messageGo to next message
Littlefoot
Messages: 21648
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
For such a simple problem, you'd perhaps rather use SUBSTR + INSTR combination (as showed in RESULT2).

Anyway, see if this helps. Query you might be interested in begins at line #6:

SQL> with test (col) as
  2    (select '[LZ3oXoFsOJo] Title A' from dual union all
  3     select '[hGYM1XZrKyg] Tile B'  from dual union all
  4     select '[5SYJN0W] Tile C'      from dual
  5    )
  6  select col,
  7         regexp_replace(col, '\[.+\] ', '') result1,
  8         --
  9         substr(col, instr(col, ']') + 2) result2
 10  from test;

COL                   RESULT1    RESULT2
--------------------- ---------- ----------
[LZ3oXoFsOJo] Title A Title A    Title A
[hGYM1XZrKyg] Tile B  Tile B     Tile B
[5SYJN0W] Tile C      Tile C     Tile C

SQL>
Re: Regex Help [message #683399 is a reply to message #683398] Thu, 07 January 2021 12:56 Go to previous message
ssmith001
Messages: 37
Registered: August 2018
Member
perfect, thanks!
Previous Topic: opening and closing balance
Next Topic: DBMS_HS_PASSTHROUGH - Database Link as Input Parameter
Goto Forum:
  


Current Time: Fri Jan 22 06:51:47 CST 2021