Search notes:

Oracle SQL function: REGEXP_COUNT

regexp_count returns how many times a given regular expression is matched in a string.
create table tq84_regexp_count (
  txt varchar2(30)
);

create table tq84_regular_expressions (
  re  varchar2(10)
);

insert into tq84_regexp_count values ('Hello World');
insert into tq84_regexp_count values ('GBP 17.30 and USD 18.25');

insert into tq84_regular_expressions values ('o'  );
insert into tq84_regular_expressions values ('.'  );
insert into tq84_regular_expressions values ('\.' );
insert into tq84_regular_expressions values ('\d' );
insert into tq84_regular_expressions values ('\d+');

select txt, re, regexp_count(txt, re) cnt
  from tq84_regexp_count, tq84_regular_expressions;


drop table tq84_regular_expressions;
drop table tq84_regexp_count purge;
Github repository Oracle-Patterns, path: /SQL/functions/regular_expressions/regexp_count.sql

See also

Oracle functions for regular expressions

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1758206307, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/Oracle/SQL/functions/regular_expressions/regexp_count/index(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78