regexp_substr [message #649302] |
Tue, 22 March 2016 02:14 |
pointers
Messages: 451 Registered: May 2008
|
Senior Member |
|
|
Hi,
Could you please help me in understanding how "regexp_substr" with match parameters 'n' and 'm' are used.
I read it as below but could not compose an example -
Quote: 'n' allows the period (.), which is the match-any-character character, to match the newline character. If you omit this parameter, then the period does not match the newline character.
◦'m' treats the source string as multiple lines. Oracle interprets the caret (^) and dollar sign ($) as the start and end, respectively, of any line anywhere in the source string, rather than only at the start or end of the entire source string. If you omit this parameter, then Oracle treats the source string as a single line.
Thank you in advance.
Regards,
Pointers
|
|
|
Re: regexp_substr [message #649303 is a reply to message #649302] |
Tue, 22 March 2016 02:34 |
|
Michel Cadot
Messages: 68645 Registered: March 2007 Location: Nanterre, France, http://...
|
Senior Member Account Moderator |
|
|
SQL> col without_n format a9
SQL> col with_n format a6
SQL> with
2 data as (
3 select 'Michel AB
4 C Cadot DB' val from dual
5 )
6 select regexp_substr(val, 'B.C') without_n,
7 regexp_substr(val, 'B.C', 1, 1, 'n') with_n
8 from data
9 /
WITHOUT_N WITH_N
--------- ------
B
C
1 row selected.
SQL> col single_line format a11
SQL> col multiple_line format a13
SQL> with
2 data as (
3 select 'Michel AB
4 C Cadot DB' val from dual
5 )
6 select regexp_substr(val, '.B$') single_line,
7 regexp_substr(val, '.B$', 1, 1, 'm') multiple_line
8 from data
9 /
SINGLE_LINE MULTIPLE_LINE
----------- -------------
DB AB
1 row selected.
[Updated on: Tue, 22 March 2016 02:35] Report message to a moderator
|
|
|
|