Regex Help [message #683397] |
Thu, 07 January 2021 12:25 |
|
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 |
|
Littlefoot
Messages: 21811 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 #683507 is a reply to message #683399] |
Mon, 25 January 2021 05:16 |
Bill B
Messages: 1971 Registered: December 2004
|
Senior Member |
|
|
If you can use the substr/instr. It is faster then user a regular expression. if it's only a few rows then use either. If your scanning millions of rows then use the substr/instr
|
|
|