REGEXP_SUBSTRを使用します (ドキュメント
)、正しい正規表現を使用します。例:
select regexp_substr('Chapter 18 Unit 10 Sect 16', 'Chapter \d*') from dual;
--Will return: Chapter 18
select regexp_substr('Chapter 18 Unit 10 Sect 16', 'Unit \d*') from dual;
--Will return: Unit 10
select regexp_substr('Chapter 18 Unit 10 Sect 16', 'Sect \d*') from dual;
--Will return: Sect 16
もちろん、Chapter xx Unit yy Sect zzを保存する場合 テーブル内の文字列の場合、この種のクエリを使用するだけで、複数の結果を取得できます。
select regexp_substr(info_column, 'Chapter \d*') from mytable;
\dを置き換えることができます [0-9]を使用 または[[:digit:]]