On Tue, Jul 13, 2021 at 02:24:01AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/13/functions-string.html
> Description:
>
> Hopefully the referrer page was kept. I'm referring to the string functions
> page that reads...
> ==
> position ( substring text IN string text ) → integer
> Returns starting index of specified substring within string, or zero if it's
> not present.
> position('om' in 'Thomas') → 3
> ==
>
> should describe the situation where multiple occurrences of substring are in
> the string text... might read...
>
> Returns starting index of the first occurrence of the specified substring
> within string, or zero if it's not present.
Interesting. I see several cases where our docs are not clear we
process only the first match:
SELECT substring ('abc abd' FROM 'b.');
substring
-----------
bc
SELECT regexp_match('abc abd', 'b.');
regexp_match
--------------
{bc}
SELECT regexp_replace ('abc abf', 'b.', 'dd');
regexp_replace
----------------
add abf
SELECT strpos('abcb', 'b');
strpos
--------
2
SELECT position('a' IN 'abca');
position
----------
1
The attached patch improves these. I can backpatch this were
appropriate.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EDB https://enterprisedb.com
If only the physical world exists, free will is an illusion.