Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unbalanced `^` and `$` anchors in Oracle regexp

Tags:

regex

oracle

Why in some cases number of start-of-string anchors is not equal to number of end-of-string anchors?

regexp_count(chr(10)||'A'||chr(10)||'B', '^') = 2
regexp_count(chr(10)||'A'||chr(10)||'B', '$') = 1

UPD :
In multi-line mode disbalance has opposite direction:

regexp_count(chr(10)||'A'||chr(10)||'B', '^', 1, 'mn') = 1 
regexp_count(chr(10)||'A'||chr(10)||'B', '$', 1, 'mn') = 3

fiddle

like image 591
Egor Skriptunoff Avatar asked Apr 18 '13 23:04

Egor Skriptunoff


1 Answers

After investigation Oracle Support concluded that this issue is a bug.

Bug 16707134 : REGEXP_COUNT PATTERN '^' AND NEW LINE UNEXPECTED BEHAVIOR

like image 174
ThinkJet Avatar answered Nov 16 '22 03:11

ThinkJet