Home » SQL & PL/SQL » SQL & PL/SQL » regexp_substr (Oracle 11.2.0.3)
regexp_substr [message #649302] Tue, 22 March 2016 02:14 Go to next message
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 Go to previous messageGo to next message
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

Re: regexp_substr [message #649304 is a reply to message #649303] Tue, 22 March 2016 02:49 Go to previous message
pointers
Messages: 451
Registered: May 2008
Senior Member

This is really helpful.

Thank you very much Michel.

Regards,
Pointers
Previous Topic: saving the htp buffer to a file
Next Topic: Split the Sum in 03 Portions
Goto Forum:
  


Current Time: Thu Apr 25 18:47:19 CDT 2024